mizzkey/src/api/stream/othello-game.ts

13 lines
406 B
TypeScript
Raw Normal View History

2018-03-07 03:40:40 +01:00
import * as websocket from 'websocket';
import * as redis from 'redis';
export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient): void {
const game = request.resourceURL.query.game;
// Subscribe game stream
subscriber.subscribe(`misskey:othello-game-stream:${game}`);
subscriber.on('message', (_, data) => {
connection.send(data);
});
}