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