0.2.4 • Published 4 years ago

@dcefram/xjs v0.2.4

Weekly downloads
20
License
SEE LICENSE IN LI...
Repository
github
Last release
4 years ago

WARNING: This is still very much a work-in-progress!

XJS Framework

The XSplit JS Framework allows developers to create plugins for XSplit Broadcaster.

This branch is the proposed next version of XJS Framework. Further documentation will be done down the line.

Remote

import XJS from 'xjs';
import { XjsTypes } from 'xjs/core/xjs/types';

// Establish connection
const Connection = () => {
  return new Promise(resolve => {
    if (RTCPeerConnection !== undefined) {
      const rtc = new RTCPeerConnection();

      rtc.ondatachannel = channel => {
        resolve(channel);
      };

      return;
    }

    const ws = new WebSocket('ws://localhost:9999');

    return resolve(ws);
  });
};

(async () => {
  // PROXY using RTC
  const conn = (await Connection()) as RTCDataChannel;

  conn.addEventListener('open', d => {
    const xjs = new XJS({
      type: XjsTypes.Proxy,
      sendMessage: conn.send.bind(conn),
    });

    conn.addEventListener('message', ({ data: message }) => {
      xjs.remote.receiveMessage(message);
    });
  });
})();

(async () => {
  // PROXY using WebSocket
  const conn = (await Connection()) as WebSocket;

  conn.addEventListener('open', d => {
    const xjs = new XJS({
      type: XjsTypes.Proxy,
      sendMessage: conn.send.bind(conn),
    });

    conn.addEventListener('message', ({ data: message }) => {
      xjs.remote.receiveMessage(message);
    });
  });
})();

(async () => {
  // REMOTE using WebSocket
  const conn = (await Connection()) as RTCDataChannel;

  conn.addEventListener('open', d => {
    const xjs = new XJS({
      type: XjsTypes.Remote,
      sendMessage: conn.send.bind(conn),
    });

    conn.addEventListener('message', ({ data: message }) => {
      xjs.remote.receiveMessage(message);
    });
  });
})();

(async () => {
  // REMOTE using WebSocket
  const conn = (await Connection()) as WebSocket;

  conn.addEventListener('open', d => {
    const xjs = new XJS({
      type: XjsTypes.Remote,
      sendMessage: conn.send.bind(conn),
    });

    conn.addEventListener('message', ({ data: message }) => {
      xjs.remote.receiveMessage(message);
    });
  });
})();
0.2.4

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.1.20

4 years ago

0.1.19

4 years ago

0.1.18

4 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago