2017-11-13 11:58:29 +01:00
|
|
|
import * as websocket from 'websocket';
|
|
|
|
import Xev from 'xev';
|
|
|
|
|
|
|
|
const ev = new Xev();
|
|
|
|
|
2018-03-07 03:40:40 +01:00
|
|
|
export default function(request: websocket.request, connection: websocket.connection): void {
|
2017-11-13 11:58:29 +01:00
|
|
|
const onRequest = request => {
|
|
|
|
connection.send(JSON.stringify({
|
|
|
|
type: 'request',
|
|
|
|
body: request
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
|
|
|
|
ev.addListener('request', onRequest);
|
|
|
|
|
|
|
|
connection.on('close', () => {
|
|
|
|
ev.removeListener('request', onRequest);
|
|
|
|
});
|
|
|
|
}
|