mirror of
https://github.com/syuilo/ai.git
synced 2024-11-09 15:38:00 +00:00
WebScoket再接続できるように再度修正
This commit is contained in:
parent
70f3c31989
commit
a12d5b07d9
|
@ -15,7 +15,7 @@
|
|||
"mecab-async": "0.1.2",
|
||||
"misskey-reversi": "0.0.5",
|
||||
"promise-retry": "1.1.1",
|
||||
"reconnecting-websocket": "3.2.2",
|
||||
"reconnecting-websocket": "4.0.0-rc5",
|
||||
"request": "2.87.0",
|
||||
"request-promise-native": "1.0.5",
|
||||
"seedrandom": "2.4.3",
|
||||
|
|
|
@ -70,7 +70,7 @@ export default class 藍 {
|
|||
|
||||
//#region Home stream
|
||||
this.connection = new ReconnectingWebSocket(`${config.wsUrl}/?i=${config.i}`, [], {
|
||||
constructor: WebSocket
|
||||
WebSocket: WebSocket
|
||||
});
|
||||
|
||||
this.connection.addEventListener('open', () => {
|
||||
|
@ -79,6 +79,7 @@ export default class 藍 {
|
|||
|
||||
this.connection.addEventListener('close', () => {
|
||||
console.log('home stream closed');
|
||||
this.connection._shouldReconnect && this.connection._connect()
|
||||
});
|
||||
|
||||
this.connection.addEventListener('message', message => {
|
||||
|
@ -90,7 +91,7 @@ export default class 藍 {
|
|||
|
||||
//#region Local timeline stream
|
||||
this.localTimelineConnection = new ReconnectingWebSocket(`${config.wsUrl}/local-timeline?i=${config.i}`, [], {
|
||||
constructor: WebSocket
|
||||
WebSocket: WebSocket
|
||||
});
|
||||
|
||||
this.localTimelineConnection.addEventListener('open', () => {
|
||||
|
@ -99,6 +100,7 @@ export default class 藍 {
|
|||
|
||||
this.localTimelineConnection.addEventListener('close', () => {
|
||||
console.log('local-timeline stream closed');
|
||||
this.localTimelineConnection._shouldReconnect && this.localTimelineConnection._connect()
|
||||
});
|
||||
|
||||
this.localTimelineConnection.addEventListener('message', message => {
|
||||
|
|
|
@ -23,7 +23,7 @@ export default class ReversiModule implements IModule {
|
|||
this.ai = ai;
|
||||
|
||||
this.reversiConnection = new ReconnectingWebSocket(`${config.wsUrl}/games/reversi?i=${config.i}`, [], {
|
||||
constructor: WebSocket
|
||||
WebSocket: WebSocket
|
||||
});
|
||||
|
||||
this.reversiConnection.addEventListener('open', () => {
|
||||
|
@ -32,6 +32,7 @@ export default class ReversiModule implements IModule {
|
|||
|
||||
this.reversiConnection.addEventListener('close', () => {
|
||||
console.log('reversi stream closed');
|
||||
this.reversiConnection._shouldReconnect && this.reversiConnection._connect()
|
||||
});
|
||||
|
||||
this.reversiConnection.addEventListener('message', message => {
|
||||
|
@ -97,7 +98,7 @@ export default class ReversiModule implements IModule {
|
|||
private onReversiGameStart = (game: any) => {
|
||||
// ゲームストリームに接続
|
||||
const gw = new ReconnectingWebSocket(`${config.wsUrl}/games/reversi-game?i=${config.i}&game=${game.id}`, [], {
|
||||
constructor: WebSocket
|
||||
WebSocket: WebSocket
|
||||
});
|
||||
|
||||
function send(msg) {
|
||||
|
@ -189,6 +190,7 @@ export default class ReversiModule implements IModule {
|
|||
|
||||
gw.addEventListener('close', () => {
|
||||
console.log('reversi game stream closed');
|
||||
gw._shouldReconnect && gw._connect()
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ export default class ServerModule implements IModule {
|
|||
this.ai = ai;
|
||||
|
||||
this.connection = new ReconnectingWebSocket(`${config.wsUrl}/server-stats`, [], {
|
||||
constructor: WebSocket
|
||||
WebSocket: WebSocket
|
||||
});
|
||||
|
||||
this.connection.addEventListener('open', () => {
|
||||
|
@ -32,6 +32,7 @@ export default class ServerModule implements IModule {
|
|||
|
||||
this.connection.addEventListener('close', () => {
|
||||
console.log('server-stats stream closed');
|
||||
this.connection._shouldReconnect && this.connection._connect()
|
||||
});
|
||||
|
||||
this.connection.addEventListener('message', message => {
|
||||
|
|
Loading…
Reference in a new issue