mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-28 22:49:24 +09:00
20 lines
419 B
TypeScript
20 lines
419 B
TypeScript
import * as websocket from 'websocket';
|
|
import Xev from 'xev';
|
|
|
|
const ev = new Xev();
|
|
|
|
export default function(request: websocket.request, connection: websocket.connection): void {
|
|
const onRequest = request => {
|
|
connection.send(JSON.stringify({
|
|
type: 'request',
|
|
body: request
|
|
}));
|
|
};
|
|
|
|
ev.addListener('request', onRequest);
|
|
|
|
connection.on('close', () => {
|
|
ev.removeListener('request', onRequest);
|
|
});
|
|
}
|