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

14 lines
449 B
TypeScript
Raw Normal View History

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