Created
July 30, 2020 12:53
-
-
Save MagnusThor/0cf03ec8ad30118d4e8ff127d1a1348e to your computer and use it in GitHub Desktop.
thor.io.client-vnext tiuny example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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