Commit 97586ae1 authored by legoc's avatar legoc
Browse files

Some outputs for sockets to debug instability

parent dd075930
......@@ -9,9 +9,29 @@ class WebReceiver extends Receiver {
this._wss = value;
this._listeners = {};
this._wss.onclose = (event) => {
console.log('Web receiver socket has closed: ', event);
};
this._wss.onerror = (event) => {
console.log('Web receiver socket is on error: ', event);
};
this._wss.on('connection', (ws) => {
console.log('Connecting socket');
ws.onclose = (event) => {
console.log('Connected socket has closed');
};
ws.onerror = (event) => {
console.log('Connected socket is on error: ', event);
};
// Handle request
ws.on('message', (data) => {
let packet = JSON.parse(data);
// Try to find the listener for the requested action
let res = this._listeners[packet.event](packet.event, packet.data);
......
......@@ -12,6 +12,14 @@ class WebSender extends Sender {
this._wss.on('connection', (ws) => {
this._ws = ws;
});
this._wss.onclose = (event) => {
console.log('Web sender socket has closed');
};
this._wss.onerror = (event) => {
console.log('Web sender socket is on error: ', event);
};
}
send(req, data) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment