diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/DocServer.ts | 1 | ||||
-rw-r--r-- | src/server/server_Initialization.ts | 2 | ||||
-rw-r--r-- | src/server/websocket.ts | 22 |
3 files changed, 13 insertions, 12 deletions
diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts index 80fccf7bc..321572071 100644 --- a/src/client/DocServer.ts +++ b/src/client/DocServer.ts @@ -190,6 +190,7 @@ export namespace DocServer { USER_ID = identifier; protocol = protocol.startsWith('https') ? 'wss' : 'ws'; _socket = io(`${protocol}://${hostname}:${port}`, { transports: ['websocket'], rejectUnauthorized: false }); + _socket.on("connect_error", (err:any) => console.log(err)); // io.connect(`https://7f079dda.ngrok.io`);// if using ngrok, create a special address for the websocket _GetCachedRefField = _GetCachedRefFieldImpl; diff --git a/src/server/server_Initialization.ts b/src/server/server_Initialization.ts index afc6231e5..2d52ea906 100644 --- a/src/server/server_Initialization.ts +++ b/src/server/server_Initialization.ts @@ -58,7 +58,7 @@ export default async function InitializeServer(routeSetter: RouteSetter) { // initialize the web socket (bidirectional communication: if a user changes // a field on one client, that change must be broadcast to all other clients) - await WebSocket.initialize(isRelease, app); + await WebSocket.initialize(isRelease, SSL.Credentials); //disconnect = async () => new Promise<Error>(resolve => server.close(resolve)); return isRelease; diff --git a/src/server/websocket.ts b/src/server/websocket.ts index 8b60caad2..38134f2c1 100644 --- a/src/server/websocket.ts +++ b/src/server/websocket.ts @@ -1,22 +1,21 @@ import { blue } from 'colors'; -import * as express from 'express'; import { createServer } from 'https'; -import { Server, Socket } from 'socket.io'; +import * as _ from 'lodash'; import { networkInterfaces } from 'os'; +import { Server, Socket } from 'socket.io'; import { Utils } from '../Utils'; import { logPort } from './ActionUtilities'; import { timeMap } from './ApiManagers/UserManager'; -import { GoogleCredentialsLoader, SSL } from './apis/google/CredentialsLoader'; -import YoutubeApi from './apis/youtube/youtubeApiSample'; -import { initializeGuest } from './authentication/DashUserModel'; import { Client } from './Client'; import { DashStats } from './DashStats'; -import { Database } from './database'; import { DocumentsCollection } from './IDatabase'; import { Diff, GestureContent, MessageStore, MobileDocumentUploadContent, MobileInkOverlayContent, Transferable, Types, UpdateMobileInkOverlayPositionContent, YoutubeQueryInput, YoutubeQueryTypes } from './Message'; import { Search } from './Search'; +import { GoogleCredentialsLoader } from './apis/google/CredentialsLoader'; +import YoutubeApi from './apis/youtube/youtubeApiSample'; +import { initializeGuest } from './authentication/DashUserModel'; +import { Database } from './database'; import { resolvedPorts } from './server_Initialization'; -import * as _ from 'lodash'; export namespace WebSocket { export let _socket: Socket; @@ -25,15 +24,16 @@ export namespace WebSocket { export const userOperations = new Map<string, number>(); export let disconnect: Function; - export async function initialize(isRelease: boolean, app: express.Express) { + export async function initialize(isRelease: boolean, credentials:any) { let io: Server; if (isRelease) { const { socketPort } = process.env; if (socketPort) { resolvedPorts.socket = Number(socketPort); - } - io = new Server(createServer(SSL.Credentials, app), SSL.Credentials as any); - io.listen(resolvedPorts.socket); + } + const httpsServer = createServer(credentials); + io = new Server(httpsServer, {}) + httpsServer.listen(resolvedPorts.socket); } else { io = new Server(); io.listen(resolvedPorts.socket); |