@@ -232,15 +232,24 @@ define(['jquery', 'underscore', 'mediastream/utils', 'mediastream/peerconnection
232232
233233 PeerCall . prototype . onMessage = function ( event ) {
234234
235- console . log ( "Peer to peer channel message" , event ) ;
236- if ( event . data instanceof Blob ) {
237- console . warn ( "Blob data received - not implemented." , event . data ) ;
238- } else if ( event . data instanceof ArrayBuffer ) {
239- console . warn ( "ArrayBuffer data received - not implemented." , event . data ) ;
235+ //console.log("Peer to peer channel message", event);
236+ var data = event . data ;
237+
238+ if ( data instanceof Blob ) {
239+ console . warn ( "Blob data received - not implemented." , data ) ;
240+ } else if ( data instanceof ArrayBuffer ) {
241+ console . warn ( "ArrayBuffer data received - not implemented." , data ) ;
242+ } else if ( typeof data === "string" ) {
243+ if ( data . charCodeAt ( 0 ) === 2 ) {
244+ // Ignore whatever shit is this (sent by Chrome 34 and FireFox). Feel free to
245+ // change the comment it you know what this is.
246+ return ;
247+ }
248+ //console.log("Datachannel message", [event.data, event.data.length, event.data.charCodeAt(0)]);
249+ var msg = JSON . parse ( event . data ) ;
250+ this . webrtc . api . received ( { Type : msg . Type , Data : msg , To : this . webrtc . api . id , From : this . id , p2p : true } ) ; //XXX(longsleep): use event for this?
240251 } else {
241- //console.log("Datachannel message", event.data);
242- var msg = JSON . parse ( event . data ) ;
243- this . webrtc . api . received ( { Type : msg . Type , Data : msg , To : this . webrtc . api . id , From : this . id , p2p : true } ) ; //XXX(longsleep): use event for this?
252+ console . warn ( "Unknow data type received -> igored" , typeof data , [ data ] ) ;
244253 }
245254
246255 } ;
0 commit comments