This commit is contained in:
syuilo 2018-10-08 00:58:10 +09:00
parent 361ab00c61
commit 305915611e
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
2 changed files with 9 additions and 8 deletions

View file

@ -24,6 +24,7 @@ export default class Connection {
public subscriber: Xev; public subscriber: Xev;
private channels: Channel[] = []; private channels: Channel[] = [];
private subscribingNotes: any = {}; private subscribingNotes: any = {};
public sendMessageToWsOverride: any = null; // 後方互換性のため
constructor( constructor(
wsConnection: websocket.connection, wsConnection: websocket.connection,
@ -164,6 +165,7 @@ export default class Connection {
*/ */
@autobind @autobind
public sendMessageToWs(type: string, payload: any) { public sendMessageToWs(type: string, payload: any) {
if (this.sendMessageToWsOverride) return this.sendMessageToWsOverride(type, payload); // 後方互換性のため
this.wsConnection.send(JSON.stringify({ this.wsConnection.send(JSON.stringify({
type: type, type: type,
body: payload body: payload

View file

@ -25,7 +25,7 @@ module.exports = (server: http.Server) => {
// 後方互換性のため // 後方互換性のため
if (request.resourceURL.pathname !== '/streaming') { if (request.resourceURL.pathname !== '/streaming') {
main.sendMessageToWs = (type: string, payload: any) => { main.sendMessageToWsOverride = (type: string, payload: any) => {
if (type == 'channel') { if (type == 'channel') {
type = payload.type; type = payload.type;
payload = payload.body; payload = payload.body;
@ -35,14 +35,13 @@ module.exports = (server: http.Server) => {
body: payload body: payload
})); }));
}; };
if (request.resourceURL.pathname === '/') {
main.connectChannel(Math.random().toString(), null, main.connectChannel(Math.random().toString(), null,
request.resourceURL.pathname === '/' ? channels.homeTimeline : request.resourceURL.pathname === '/' ? channels.homeTimeline :
request.resourceURL.pathname === '/local-timeline' ? channels.localTimeline : request.resourceURL.pathname === '/local-timeline' ? channels.localTimeline :
request.resourceURL.pathname === '/hybrid-timeline' ? channels.hybridTimeline : request.resourceURL.pathname === '/hybrid-timeline' ? channels.hybridTimeline :
request.resourceURL.pathname === '/global-timeline' ? channels.globalTimeline : null); request.resourceURL.pathname === '/global-timeline' ? channels.globalTimeline : null);
} }
}
connection.once('close', () => { connection.once('close', () => {
ev.removeAllListeners(); ev.removeAllListeners();