File tree 4 files changed +2119
-543
lines changed
4 files changed +2119
-543
lines changed Original file line number Diff line number Diff line change 3
3
import config from 'config' ;
4
4
import Daemon from 'daemon' ;
5
5
import session from 'express-session' ;
6
- import socketio from 'socket.io' ;
7
6
import SessionStore from '@edenjs/session-store' ;
8
7
import cookieParser from 'cookie-parser' ;
8
+ import { Server } from 'socket.io' ;
9
9
import { v4 as uuid } from 'uuid' ;
10
10
11
11
// require models
@@ -80,7 +80,9 @@ export default class SocketDaemon extends Daemon {
80
80
} ) ;
81
81
82
82
// Set io
83
- this . __socketIO = socketio ( this . eden . router . app . server ) ;
83
+ this . __socketIO = new Server ( this . eden . router . app . server , {
84
+ allowEIO3 : true ,
85
+ } ) ;
84
86
85
87
// initialize store
86
88
SessionStore . initialize ( session ) ;
Original file line number Diff line number Diff line change 1
1
2
2
// Require dependencies
3
- const io = require ( 'socket.io-client' ) ;
4
- const uuid = require ( 'uuid' ) . v4 ;
3
+ import io from 'socket.io-client' ;
4
+ import { v4 as uuid } from 'uuid' ;
5
5
6
6
// Require local dependencies
7
- const store = require ( 'core/public/js/store' ) ;
7
+ import store from 'core/public/js/store' ;
8
8
9
9
/**
10
10
* Build socket class
@@ -34,8 +34,9 @@ class SocketStore {
34
34
*/
35
35
async build ( ) {
36
36
// Run socket
37
- this . socket = io . connect ( store . get ( 'config.socket.url' ) === 'host' ? `//${ window . location . hostname } ` : store . get ( 'config.socket.url' ) ,
38
- store . get ( 'config.socket.params' ) || { } ) ;
37
+ this . socket = io . connect ( store . get ( 'config.socket.url' ) === 'host' ? null : store . get ( 'config.socket.url' ) , {
38
+ ...( store . get ( 'config.socket.params' ) || { } ) ,
39
+ } ) ;
39
40
40
41
// socket on
41
42
this . socket . on ( 'connect' , ( ) => {
@@ -162,4 +163,7 @@ class SocketStore {
162
163
*
163
164
* @type {SocketStore }
164
165
*/
165
- exports = module . exports = window . eden . socket = new SocketStore ( ) ;
166
+ window . eden . socket = new SocketStore ( ) ;
167
+
168
+ // export default
169
+ export default window . eden . socket ;
You can’t perform that action at this time.
0 commit comments