summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-03-14 06:58:40 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-03-14 06:58:40 +0900
commita1e5420b8ffbb13097d65dfa5ea677f0a7e034f0 (patch)
tree28cdb191b3d2e3a70a3d30de52f497df8e025d00 /src/common
parentv4128 (diff)
downloadsharkey-a1e5420b8ffbb13097d65dfa5ea677f0a7e034f0.tar.gz
sharkey-a1e5420b8ffbb13097d65dfa5ea677f0a7e034f0.tar.bz2
sharkey-a1e5420b8ffbb13097d65dfa5ea677f0a7e034f0.zip
Use ReconnectingWebSocket
Diffstat (limited to 'src/common')
-rw-r--r--src/common/othello/ai/front.ts15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/common/othello/ai/front.ts b/src/common/othello/ai/front.ts
index 99cf1a712d..838e5a1430 100644
--- a/src/common/othello/ai/front.ts
+++ b/src/common/othello/ai/front.ts
@@ -7,7 +7,8 @@
*/
import * as childProcess from 'child_process';
-import * as WebSocket from 'ws';
+const WebSocket = require('ws');
+import * as ReconnectingWebSocket from 'reconnecting-websocket';
import * as request from 'request-promise-native';
import conf from '../../../conf';
@@ -28,7 +29,9 @@ const id = conf.othello_ai.id;
/**
* ホームストリーム
*/
-const homeStream = new WebSocket(`wss://api.misskey.xyz/?i=${i}`);
+const homeStream = new ReconnectingWebSocket(`wss://api.misskey.xyz/?i=${i}`, undefined, {
+ constructor: WebSocket
+});
homeStream.on('open', () => {
console.log('home stream opened');
@@ -97,7 +100,9 @@ function invite(userId) {
/**
* オセロストリーム
*/
-const othelloStream = new WebSocket(`wss://api.misskey.xyz/othello?i=${i}`);
+const othelloStream = new ReconnectingWebSocket(`wss://api.misskey.xyz/othello?i=${i}`, undefined, {
+ constructor: WebSocket
+});
othelloStream.on('open', () => {
console.log('othello stream opened');
@@ -127,7 +132,9 @@ othelloStream.on('message', message => {
*/
function gameStart(game) {
// ゲームストリームに接続
- const gw = new WebSocket(`wss://api.misskey.xyz/othello-game?i=${i}&game=${game.id}`);
+ const gw = new ReconnectingWebSocket(`wss://api.misskey.xyz/othello-game?i=${i}&game=${game.id}`, undefined, {
+ constructor: WebSocket
+ });
gw.on('open', () => {
console.log('othello game stream opened');