2017-10-31 18:17:14 +00:00
|
|
|
import * as websocket from 'websocket';
|
|
|
|
import * as redis from 'redis';
|
2018-03-29 11:32:18 +00:00
|
|
|
import { ParsedUrlQuery } from 'querystring';
|
2017-10-31 18:17:14 +00:00
|
|
|
|
|
|
|
export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient): void {
|
2018-03-29 11:32:18 +00:00
|
|
|
const q = request.resourceURL.query as ParsedUrlQuery;
|
|
|
|
const channel = q.channel;
|
2017-10-31 18:17:14 +00:00
|
|
|
|
|
|
|
// Subscribe channel stream
|
|
|
|
subscriber.subscribe(`misskey:channel-stream:${channel}`);
|
|
|
|
subscriber.on('message', (_, data) => {
|
|
|
|
connection.send(data);
|
|
|
|
});
|
|
|
|
}
|