Code Monkey home page Code Monkey logo

Comments (5)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 11, 2024
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 [email protected] on 16 May 2012 at 8:46

from sipml5.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 11, 2024
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 [email protected] on 16 May 2012 at 10:12

from sipml5.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 11, 2024
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 [email protected] on 16 May 2012 at 11:09

  • Changed state: Accepted

from sipml5.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 11, 2024
>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 [email protected] on 17 May 2012 at 8:24

from sipml5.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 11, 2024
Fixed by r54

Original comment by [email protected] on 17 May 2012 at 9:51

  • Changed state: Fixed

from sipml5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.