Merge pull request #11 from mei23/mei-0924-webscoket

WebSocket再接続が速すぎるのを修正
This commit is contained in:
syuilo 2018-09-24 14:37:40 +09:00 committed by GitHub
commit 681dae73cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 17 deletions

View file

@ -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",

View file

@ -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 => {

View file

@ -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 => {

View file

@ -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 => {