File tree Expand file tree Collapse file tree 1 file changed +25
-8
lines changed
Expand file tree Collapse file tree 1 file changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -156,16 +156,33 @@ JsSIP.Transport.prototype = {
156156 var message , transaction ,
157157 data = e . data ;
158158
159- if ( this . ua . configuration . trace_sip === true ) {
160- console . info ( JsSIP . c . LOG_TRANSPORT + 'Received WebSocket message: \n\n' + data + '\n' ) ;
161- }
162-
163- // Keep alive response from server. Scape it.
159+ // CRLF Keep Alive response from server. Ignore it.
164160 if ( data === '\r\n' ) {
161+ if ( this . ua . configuration . trace_sip === true ) {
162+ console . info ( JsSIP . c . LOG_TRANSPORT + 'Received WebSocket message with CRLF Keep Alive response' ) ;
163+ }
165164 return ;
166- } else if ( typeof data !== 'string' ) {
167- console . info ( JsSIP . c . LOG_TRANSPORT + 'Binary data received. Ignoring message\n' ) ;
168- return ;
165+ }
166+
167+ // WebSocket binary message.
168+ else if ( typeof data !== 'string' ) {
169+ try {
170+ data = String . fromCharCode . apply ( null , new Uint8Array ( e . data ) ) ;
171+ } catch ( e ) {
172+ console . warn ( JsSIP . c . LOG_TRANSPORT + 'Received WebSocket binary message failed to be converted into String, message ignored' ) ;
173+ return ;
174+ }
175+
176+ if ( this . ua . configuration . trace_sip === true ) {
177+ console . info ( JsSIP . c . LOG_TRANSPORT + 'Received WebSocket binary message: \n\n' + data + '\n' ) ;
178+ }
179+ }
180+
181+ // WebSocket text message.
182+ else {
183+ if ( this . ua . configuration . trace_sip === true ) {
184+ console . info ( JsSIP . c . LOG_TRANSPORT + 'Received WebSocket text message: \n\n' + data + '\n' ) ;
185+ }
169186 }
170187
171188 message = JsSIP . Parser . parseMessage ( data ) ;
You can’t perform that action at this time.
0 commit comments