Skip to content

Instantly share code, notes, and snippets.

@MagnusThor
Created July 30, 2020 12:53
Show Gist options
  • Save MagnusThor/0cf03ec8ad30118d4e8ff127d1a1348e to your computer and use it in GitHub Desktop.
Save MagnusThor/0cf03ec8ad30118d4e8ff127d1a1348e to your computer and use it in GitHub Desktop.
thor.io.client-vnext tiuny example
import { ClientFactory, WebRTCFactory, BinaryMessage, TextMessage, Controller } from 'thor-io.client-vnext'
export class TestClient{
factory: ClientFactory;
controller: Controller;
constructor(){
this.factory = new ClientFactory("ws://localhost:1337",["example"],{});
this.factory.onOpen = (controller: Controller) => {
this.controller = controller;
console.log(`a connection is made to example`,controller);
controller.connect();
};
}
}
document.addEventListener("DOMContentLoaded",() => {
let testClient = new TestClient()
window["testClient"] = testClient; // Expose to console
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment