import { WebSocketServer } from '@awesome-cordova-plugins/web-socket-server';
constructor(private wsserver: WebSocketServer) { }
...
this.wsserver.start(8888, {}).subscribe({
next: server => console.log(`Listening on ${server.addr}:${server.port}`),
error: error => console.log(`Unexpected error`, error);
});
this.wsserver.watchMessage().subscribe(result => {
console.log(`Received message ${result.msg} from ${result.conn.uuid}`);
});
this.wsserver.send({ uuid: '8e7c4f48-de68-4b6f-8fca-1067a353968d' }, 'Hello World');
this.wsserver.stop().then(server => {
console.log(`Stop listening on ${server.addr}:${server.port}`);
});