@@ -48,20 +48,7 @@ function SignalingChannel() {
48
48
49
49
this . connect = function ( loginInfo ) {
50
50
const serverAddress = loginInfo . host ;
51
- const token = loginInfo . token ;
52
- const parameters = [ ] ;
53
- let queryString = null ;
54
- parameters . push ( 'clientType=' + clientType ) ;
55
- parameters . push ( 'clientVersion=' + clientVersion ) ;
56
- if ( token ) {
57
- parameters . push ( 'token=' + encodeURIComponent ( token ) ) ;
58
- }
59
- if ( parameters ) {
60
- queryString = parameters . join ( '&' ) ;
61
- }
62
- console . log ( 'Query string: ' + queryString ) ;
63
51
const opts = {
64
- 'query' : queryString ,
65
52
'reconnection' : true ,
66
53
'reconnectionAttempts' : MAX_TRIALS ,
67
54
'force new connection' : true ,
@@ -70,15 +57,21 @@ function SignalingChannel() {
70
57
71
58
wsServer . on ( 'connect' , function ( ) {
72
59
reconnectTimes = 0 ;
73
- console . info ( 'Connected to websocket server.' ) ;
74
- } ) ;
75
-
76
- wsServer . on ( 'server-authenticated' , function ( data ) {
77
- console . log ( 'Authentication passed. User ID: ' + data . uid ) ;
78
- if ( connectPromise ) {
79
- connectPromise . resolve ( data . uid ) ;
80
- }
81
- connectPromise = null ;
60
+ wsServer . emit ( 'authentication' , { token : loginInfo . token } , ( data ) => {
61
+ if ( data . uid ) {
62
+ console . log ( 'Authentication passed. User ID: ' + data . uid ) ;
63
+ } else {
64
+ console . error ( 'Faild to connect to Socket.IO server.' ) ;
65
+ }
66
+ if ( connectPromise ) {
67
+ if ( data . uid ) {
68
+ connectPromise . resolve ( data . uid ) ;
69
+ } else if ( data . error ) {
70
+ connectPromise . reject ( data . error ) ;
71
+ }
72
+ }
73
+ connectPromise = null ;
74
+ } ) ;
82
75
} ) ;
83
76
84
77
wsServer . on ( 'reconnecting' , function ( ) {
0 commit comments