From d4095127e96430adcb76c02e277f35e7644a7129 Mon Sep 17 00:00:00 2001 From: mei23 Date: Mon, 24 Sep 2018 14:25:58 +0900 Subject: [PATCH] =?UTF-8?q?WebSocket=E5=86=8D=E6=8E=A5=E7=B6=9A=E3=81=8C?= =?UTF-8?q?=E9=80=9F=E3=81=99=E3=81=8E=E3=82=8B=E3=81=AE=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- src/ai.ts | 10 +++------- src/modules/reversi/index.ts | 6 ++---- src/modules/server/index.ts | 6 ++---- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 7487031..bb41f26 100644 --- a/package.json +++ b/package.json @@ -10,12 +10,12 @@ "@types/node": "10.0.5", "@types/promise-retry": "1.1.2", "@types/seedrandom": "2.4.27", - "@types/ws": "5.1.2", + "@types/ws": "6.0.1", "lokijs": "1.5.5", "mecab-async": "0.1.2", "misskey-reversi": "0.0.5", "promise-retry": "1.1.1", - "reconnecting-websocket": "4.0.0-rc5", + "reconnecting-websocket": "3.2.2", "request": "2.87.0", "request-promise-native": "1.0.5", "seedrandom": "2.4.3", diff --git a/src/ai.ts b/src/ai.ts index a2161ec..58e0b20 100644 --- a/src/ai.ts +++ b/src/ai.ts @@ -9,7 +9,7 @@ import MessageLike from './message-like'; import { FriendDoc } from './friend'; import { User } from './misskey/user'; import getCollection from './utils/get-collection'; -const ReconnectingWebSocket = require('../node_modules/reconnecting-websocket/dist/reconnecting-websocket-cjs.js'); +const ReconnectingWebSocket = require('reconnecting-websocket'); /** * 藍 @@ -70,7 +70,7 @@ export default class 藍 { //#region Home stream this.connection = new ReconnectingWebSocket(`${config.wsUrl}/?i=${config.i}`, [], { - WebSocket: WebSocket + constructor: WebSocket }); this.connection.addEventListener('open', () => { @@ -79,8 +79,6 @@ export default class 藍 { this.connection.addEventListener('close', () => { console.log('home stream closed'); - - this.connection.reconnect(); }); this.connection.addEventListener('message', message => { @@ -92,7 +90,7 @@ export default class 藍 { //#region Local timeline stream this.localTimelineConnection = new ReconnectingWebSocket(`${config.wsUrl}/local-timeline?i=${config.i}`, [], { - WebSocket: WebSocket + constructor: WebSocket }); this.localTimelineConnection.addEventListener('open', () => { @@ -101,8 +99,6 @@ export default class 藍 { this.localTimelineConnection.addEventListener('close', () => { console.log('local-timeline stream closed'); - - this.localTimelineConnection.reconnect(); }); this.localTimelineConnection.addEventListener('message', message => { diff --git a/src/modules/reversi/index.ts b/src/modules/reversi/index.ts index abcd85f..f5c4697 100644 --- a/src/modules/reversi/index.ts +++ b/src/modules/reversi/index.ts @@ -1,5 +1,5 @@ import * as childProcess from 'child_process'; -const ReconnectingWebSocket = require('../../../node_modules/reconnecting-websocket/dist/reconnecting-websocket-cjs.js'); +const ReconnectingWebSocket = require('reconnecting-websocket'); import 藍 from '../../ai'; import IModule from '../../module'; import serifs from '../../serifs'; @@ -23,7 +23,7 @@ export default class ReversiModule implements IModule { this.ai = ai; this.reversiConnection = new ReconnectingWebSocket(`${config.wsUrl}/games/reversi?i=${config.i}`, [], { - WebSocket: WebSocket + constructor: WebSocket }); this.reversiConnection.addEventListener('open', () => { @@ -32,8 +32,6 @@ export default class ReversiModule implements IModule { this.reversiConnection.addEventListener('close', () => { console.log('reversi stream closed'); - - this.reversiConnection.reconnect(); }); this.reversiConnection.addEventListener('message', message => { diff --git a/src/modules/server/index.ts b/src/modules/server/index.ts index 45228b3..9d3586e 100644 --- a/src/modules/server/index.ts +++ b/src/modules/server/index.ts @@ -3,7 +3,7 @@ import 藍 from '../../ai'; import IModule from '../../module'; import serifs from '../../serifs'; import config from '../../config'; -const ReconnectingWebSocket = require('../../../node_modules/reconnecting-websocket/dist/reconnecting-websocket-cjs.js'); +const ReconnectingWebSocket = require('reconnecting-websocket'); export default class ServerModule implements IModule { public readonly name = 'server'; @@ -23,7 +23,7 @@ export default class ServerModule implements IModule { this.ai = ai; this.connection = new ReconnectingWebSocket(`${config.wsUrl}/server-stats`, [], { - WebSocket: WebSocket + constructor: WebSocket }); this.connection.addEventListener('open', () => { @@ -32,8 +32,6 @@ export default class ServerModule implements IModule { this.connection.addEventListener('close', () => { console.log('server-stats stream closed'); - - this.connection.reconnect(); }); this.connection.addEventListener('message', message => {