diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-10-07 17:19:52 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-10-07 17:19:52 +0900 |
| commit | e05acb8d18059c01e5789db043db82e4abfbd9d5 (patch) | |
| tree | dd55d03d88794e13d5d78333d0acc769da4f7a5a /src/server/api/streaming.ts | |
| parent | Improve readability a little (diff) | |
| download | sharkey-e05acb8d18059c01e5789db043db82e4abfbd9d5.tar.gz sharkey-e05acb8d18059c01e5789db043db82e4abfbd9d5.tar.bz2 sharkey-e05acb8d18059c01e5789db043db82e4abfbd9d5.zip | |
後方互換性を追加
Diffstat (limited to 'src/server/api/streaming.ts')
| -rw-r--r-- | src/server/api/streaming.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/server/api/streaming.ts b/src/server/api/streaming.ts index 4518d21c3f..b7793eb284 100644 --- a/src/server/api/streaming.ts +++ b/src/server/api/streaming.ts @@ -5,6 +5,7 @@ import Xev from 'xev'; import MainStreamConnection from './stream'; import { ParsedUrlQuery } from 'querystring'; import authenticate from './authenticate'; +import channels from './stream/channels'; module.exports = (server: http.Server) => { // Init websocket server @@ -22,6 +23,27 @@ module.exports = (server: http.Server) => { const main = new MainStreamConnection(connection, ev, user, app); + // 後方互換性のため + if (request.resourceURL.pathname !== '/streaming') { + main.sendMessageToWs = (type: string, payload: any) => { + if (type == 'channel') { + type = payload.type; + payload = payload.body; + } + connection.send(JSON.stringify({ + type: type, + body: payload + })); + }; + if (request.resourceURL.pathname === '/') { + main.connectChannel(Math.random().toString(), null, + request.resourceURL.pathname === '/' ? channels.homeTimeline : + request.resourceURL.pathname === '/local-timeline' ? channels.localTimeline : + request.resourceURL.pathname === '/hybrid-timeline' ? channels.hybridTimeline : + request.resourceURL.pathname === '/global-timeline' ? channels.globalTimeline : null); + } + } + connection.once('close', () => { ev.removeAllListeners(); main.dispose(); |