21 lines
476 B
TypeScript
21 lines
476 B
TypeScript
|
class Client {
|
||
|
private client : WebSocket;
|
||
|
private connected : boolean = false;
|
||
|
constructor () {
|
||
|
let uri : string = 'ws://localhost:8082';
|
||
|
this.client = new WebSocket(uri);
|
||
|
this.client.onopen = this.onOpen.bind(this);
|
||
|
this.client.onmessage = this.onMessage.bind(this);
|
||
|
}
|
||
|
|
||
|
private onMessage (event : any) {
|
||
|
console.log(event.data);
|
||
|
}
|
||
|
|
||
|
private onOpen (event : any) {
|
||
|
console.log('Connected');
|
||
|
this.connected = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
new Client();
|