This commit is contained in:
syuilo
2017-11-01 03:17:14 +09:00
parent e770cd6f55
commit f37fb38640
25 changed files with 189 additions and 86 deletions

View File

@@ -9,6 +9,7 @@ import isNativeToken from './common/is-native-token';
import homeStream from './stream/home';
import messagingStream from './stream/messaging';
import serverStream from './stream/server';
import channelStream from './stream/channel';
module.exports = (server: http.Server) => {
/**
@@ -26,14 +27,6 @@ module.exports = (server: http.Server) => {
return;
}
const user = await authenticate(request.resourceURL.query.i);
if (user == null) {
connection.send('authentication-failed');
connection.close();
return;
}
// Connect to Redis
const subscriber = redis.createClient(
config.redis.port, config.redis.host);
@@ -43,6 +36,19 @@ module.exports = (server: http.Server) => {
subscriber.quit();
});
if (request.resourceURL.pathname === '/channel') {
channelStream(request, connection, subscriber);
return;
}
const user = await authenticate(request.resourceURL.query.i);
if (user == null) {
connection.send('authentication-failed');
connection.close();
return;
}
const channel =
request.resourceURL.pathname === '/' ? homeStream :
request.resourceURL.pathname === '/messaging' ? messagingStream :