Closed GoogleCodeExporter closed 9 years ago
This issue is not relayted to the message content. The sipml5 does not accept
websocket.opcode == Text frame, but...
http://tools.ietf.org/html/draft-ibc-sipcore-sip-websocket-02#section-4.2
WebSocket messages are carried on top of WebSocket UTF-8 text frames
or binary frames. The SIP protocol [RFC3261] allows both text and
binary bodies in SIP messages. Therefore SIP WebSocket Clients and
SIP WebSocket Servers MUST accept both WebSocket text and binary
frames.
Original comment by i...@fomine.com
on 16 May 2012 at 8:46
Possible solution:
function __tsip_transport_ws_onmessage_for_buffer(data) {
var o_ragel_state = tsk_ragel_state_create();
tsk_ragel_state_init_ai(o_ragel_state, data);
var o_message = tsip_message.prototype.Parse(o_ragel_state, true);
if (o_message) {
//--console.debug("recv=%s", o_message.toString());
o_message.o_socket = this;
return this.o_transport.get_layer().handle_incoming_message(o_message);
}
else {
console.error("Failed to parse message: %s", data);
return -1;
}
}
function __tsip_transport_ws_onmessage(evt) {
console.debug("__tsip_transport_ws_onmessage");
if(typeof(evt.data) == 'string') {
var bb = new (window.MozBlobBuilder || window.WebKitBlobBuilder || window.BlobBuilder)();
bb.append(evt.data);
var f = new FileReader(bb.getBlob());
f.websocket = this;
f.onload = function(e) {
__tsip_transport_ws_onmessage_for_buffer.call(f.websocket, e.target.result);
}
f.readAsArrayBuffer(bb.getBlob());
}
else {
return __tsip_transport_ws_onmessage_for_buffer(evt.data);
}
}
Original comment by i...@fomine.com
on 16 May 2012 at 10:12
The problem with "DOMString" is that SIP message will not be able to contain
binary data while ArrayBuffer can contain both.
You don't need to write a new function. Try to change the ragel initializer
from:
tsk_ragel_state_init_ai(o_ragel_state, data);
to:
tsk_ragel_state_init_str(o_ragel_state, data);
Original comment by boss...@yahoo.fr
on 16 May 2012 at 11:09
>The problem with "DOMString" is that SIP message will not be able to contain
binary
But sipml5 sends text blob itself. :)
>Try to change the ragel initializer from
Yes, it works! Thank you. Will you add it to project?
if(typeof(evt.data) == 'string')
tsk_ragel_state_init_str(o_ragel_state, evt.data);
else
tsk_ragel_state_init_ai(o_ragel_state, evt.data);
Original comment by i...@fomine.com
on 17 May 2012 at 8:24
Fixed by r54
Original comment by boss...@yahoo.fr
on 17 May 2012 at 9:51
Original issue reported on code.google.com by
i...@fomine.com
on 16 May 2012 at 2:58