monkeeShark/src/server/api/stream/user-list.ts

14 lines
449 B
TypeScript
Raw Normal View History

2018-04-26 02:02:15 +00:00
import * as websocket from 'websocket';
2018-07-29 22:20:27 +00:00
import Xev from 'xev';
2018-04-26 02:02:15 +00:00
import { ParsedUrlQuery } from 'querystring';
2018-07-29 22:20:27 +00:00
export default function(request: websocket.request, connection: websocket.connection, subscriber: Xev, user: any): void {
2018-04-26 02:02:15 +00:00
const q = request.resourceURL.query as ParsedUrlQuery;
const listId = q.listId as string;
// Subscribe stream
2018-07-29 22:20:27 +00:00
subscriber.on(`user-list-stream:${listId}`, data => {
2018-08-01 02:07:30 +00:00
connection.send(JSON.stringify(data));
2018-04-26 02:02:15 +00:00
});
}