2019-07-30 09:05:41 -05:00
|
|
|
/*eslint no-unused-vars: "off"*/
|
|
|
|
|
import { WSSAdapter } from './WSSAdapter';
|
|
|
|
|
const WebSocketServer = require('ws').Server;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Wrapper for ws node module
|
|
|
|
|
*/
|
|
|
|
|
export class WSAdapter extends WSSAdapter {
|
|
|
|
|
constructor(options: any) {
|
|
|
|
|
super(options);
|
2019-07-30 20:40:54 -07:00
|
|
|
this.options = options;
|
2019-07-30 09:05:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onListen() {}
|
|
|
|
|
onConnection(ws) {}
|
2019-11-22 15:23:04 -06:00
|
|
|
onError(error) {}
|
2019-07-30 20:40:54 -07:00
|
|
|
start() {
|
|
|
|
|
const wss = new WebSocketServer({ server: this.options.server });
|
|
|
|
|
wss.on('listening', this.onListen);
|
|
|
|
|
wss.on('connection', this.onConnection);
|
2019-11-22 15:23:04 -06:00
|
|
|
wss.on('error', this.onError);
|
2019-07-30 20:40:54 -07:00
|
|
|
}
|
2019-07-30 09:05:41 -05:00
|
|
|
close() {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default WSAdapter;
|