1717 :initial-server-url =" serverUrl"
1818 :initial-ws-only =" wsOnly"
1919 :initial-path =" path"
20+ :initial-parser =" parser"
2021 :is-connecting =" isConnecting"
2122 :error =" connectionError"
2223 @submit =" onSubmit"
2829import AppBar from " ./components/AppBar" ;
2930import NavigationDrawer from " ./components/NavigationDrawer" ;
3031import { io } from " socket.io-client" ;
32+ import msgpackParser from " socket.io-msgpack-parser" ;
3133import ConnectionModal from " ./components/ConnectionModal" ;
3234import SocketHolder from " ./SocketHolder" ;
3335import { mapState } from " vuex" ;
@@ -63,6 +65,7 @@ export default {
6365 serverUrl : (state ) => state .connection .serverUrl ,
6466 wsOnly : (state ) => state .connection .wsOnly ,
6567 path : (state ) => state .connection .path ,
68+ parser : (state ) => state .connection .parser ,
6669 backgroundColor : (state ) =>
6770 state .config .darkTheme ? " " : " grey lighten-5" ,
6871 }),
@@ -84,7 +87,7 @@ export default {
8487 },
8588
8689 methods: {
87- tryConnect (serverUrl , auth , wsOnly , path ) {
90+ tryConnect (serverUrl , auth , wsOnly , path , parser ) {
8891 this .isConnecting = true ;
8992 if (SocketHolder .socket ) {
9093 SocketHolder .socket .disconnect ();
@@ -98,6 +101,7 @@ export default {
98101 withCredentials: true , // needed for cookie-based sticky-sessions
99102 transports: wsOnly ? [" websocket" ] : [" polling" , " websocket" ],
100103 path,
104+ parser: parser === " msgpack" ? msgpackParser : null ,
101105 auth,
102106 });
103107 socket .once (" connect" , () => {
@@ -110,6 +114,7 @@ export default {
110114 serverUrl,
111115 wsOnly,
112116 path,
117+ parser,
113118 });
114119 SocketHolder .socket = socket;
115120 this .registerEventListeners (socket);
@@ -121,10 +126,16 @@ export default {
121126 if (this .isConnecting || err .message === " invalid credentials" ) {
122127 this .showConnectionModal = true ;
123128 this .connectionError = err .message ;
124- this .isConnecting = false ;
125129 }
130+ this .isConnecting = false ;
126131 });
127- socket .on (" disconnect" , () => {
132+ socket .on (" disconnect" , (reason ) => {
133+ // this should not be needed, but connection errors with a mismatching parser may trigger in a "disconnect"
134+ // event instead of a "connect_error" event (needs to be fixed in the client code)
135+ if (this .isConnecting ) {
136+ this .isConnecting = false ;
137+ this .connectionError = reason;
138+ }
128139 this .$store .commit (" connection/disconnect" );
129140 });
130141 },
@@ -171,7 +182,8 @@ export default {
171182 password: form .password ,
172183 },
173184 form .wsOnly ,
174- form .path
185+ form .path ,
186+ form .parser
175187 );
176188 },
177189 },
@@ -187,7 +199,8 @@ export default {
187199 sessionId,
188200 },
189201 this .wsOnly ,
190- this .path
202+ this .path ,
203+ this .parser
191204 );
192205 } else {
193206 this .showConnectionModal = true ;
0 commit comments