summaryrefslogtreecommitdiff
path: root/src/server/api/streaming.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-07-30 07:20:27 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-07-30 07:20:27 +0900
commit83d9730d93b976c2477808e1a6275937defff300 (patch)
tree782e1d5a8d875f469223cc34e55d619347a5afe3 /src/server/api/streaming.ts
parentFix bug (diff)
downloadsharkey-83d9730d93b976c2477808e1a6275937defff300.tar.gz
sharkey-83d9730d93b976c2477808e1a6275937defff300.tar.bz2
sharkey-83d9730d93b976c2477808e1a6275937defff300.zip
#2020
Diffstat (limited to 'src/server/api/streaming.ts')
-rw-r--r--src/server/api/streaming.ts16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/server/api/streaming.ts b/src/server/api/streaming.ts
index afa0de2ce1..c8b2d4e0b9 100644
--- a/src/server/api/streaming.ts
+++ b/src/server/api/streaming.ts
@@ -1,7 +1,6 @@
import * as http from 'http';
import * as websocket from 'websocket';
-import * as redis from 'redis';
-import config from '../../config';
+import Xev from 'xev';
import homeStream from './stream/home';
import localTimelineStream from './stream/local-timeline';
@@ -39,20 +38,17 @@ module.exports = (server: http.Server) => {
return;
}
- // Connect to Redis
- const subscriber = redis.createClient(
- config.redis.port, config.redis.host);
+ const ev = new Xev();
- connection.on('close', () => {
- subscriber.unsubscribe();
- subscriber.quit();
+ connection.once('close', () => {
+ ev.removeAllListeners();
});
const q = request.resourceURL.query as ParsedUrlQuery;
const [user, app] = await authenticate(q.i as string);
if (request.resourceURL.pathname === '/games/reversi-game') {
- reversiGameStream(request, connection, subscriber, user);
+ reversiGameStream(request, connection, ev, user);
return;
}
@@ -75,7 +71,7 @@ module.exports = (server: http.Server) => {
null;
if (channel !== null) {
- channel(request, connection, subscriber, user, app);
+ channel(request, connection, ev, user, app);
} else {
connection.close();
}