Просмотр исходного кода

WIP: comment out codes which uses socket.io

Yuki Takei 5 лет назад
Родитель
Сommit
da9bbc9dbd
2 измененных файлов с 21 добавлено и 13 удалено
  1. 9 4
      src/client/js/services/WebsocketContainer.js
  2. 12 9
      src/server/crowi/index.js

+ 9 - 4
src/client/js/services/WebsocketContainer.js

@@ -1,6 +1,6 @@
 import { Container } from 'unstated';
 
-import io from 'socket.io-client';
+import ReconnectingWebSocket from 'reconnecting-websocket';
 
 /**
  * Service container related to options for WebSocket
@@ -14,12 +14,17 @@ export default class WebsocketContainer extends Container {
     this.appContainer = appContainer;
     this.appContainer.registerContainer(this);
 
-    this.socket = io();
-    this.socketClientId = Math.floor(Math.random() * 100000);
-
     this.state = {
     };
 
+    this.socket = null;
+
+    this.initSocket();
+  }
+
+  initSocket() {
+    this.socket = new ReconnectingWebSocket();
+    this.socketClientId = Math.floor(Math.random() * 100000);
   }
 
   /**

+ 12 - 9
src/server/crowi/index.js

@@ -9,8 +9,7 @@ const Xss = require('@commons/service/xss');
 const { getMongoUri, mongoOptions } = require('@commons/util/mongoose-utils');
 
 const path = require('path');
-
-const sep = path.sep;
+const WebSocket = require('ws');
 
 const mongoose = require('mongoose');
 
@@ -18,6 +17,8 @@ const models = require('../models');
 
 const PluginService = require('../plugins/plugin.service');
 
+const sep = path.sep;
+
 function Crowi(rootdir) {
   const self = this;
 
@@ -269,9 +270,10 @@ Crowi.prototype.setupModels = async function() {
   });
 };
 
-Crowi.prototype.getIo = function() {
-  return this.io;
-};
+// FIXME: with GW-3262
+// Crowi.prototype.getIo = function() {
+//   return this.io;
+// };
 
 Crowi.prototype.scanRuntimeVersions = async function() {
   const self = this;
@@ -399,10 +401,11 @@ Crowi.prototype.start = async function() {
   });
 
   // setup WebSocket
-  const io = require('socket.io')(serverListening);
-  io.sockets.on('connection', (socket) => {
-  });
-  this.io = io;
+  // FIXME: with GW-3262
+  // const io = require('socket.io')(serverListening);
+  // io.sockets.on('connection', (socket) => {
+  // });
+  // this.io = io;
 
   // setup Express Routes
   this.setupRoutesAtLast();