Sharkey/src/server/api/stream/messaging-index.ts

11 lines
388 B
TypeScript
Raw Normal View History

2017-11-13 17:54:16 +02:00
import * as websocket from 'websocket';
import * as redis from 'redis';
export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void {
// Subscribe messaging index stream
subscriber.subscribe(`misskey:messaging-index-stream:${user._id}`);
subscriber.on('message', (_, data) => {
connection.send(data);
});
}