Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket w/ binary frame #17

Closed
vf1 opened this issue Nov 13, 2012 · 4 comments
Closed

WebSocket w/ binary frame #17

vf1 opened this issue Nov 13, 2012 · 4 comments

Comments

@vf1
Copy link

vf1 commented Nov 13, 2012

jssip does not understand messages sent in binary frame.

JsSIP | TRANSPORT | Received WebSocket message: 

[object ArrayBuffer]

Binary data received. Ignoring message

Here is possible dirty solution.

  onMessage: function(e) {
    var message, transaction,
      data = (typeof e.data === 'string') ? e.data : String.fromCharCode.apply(null, new Uint8Array(e.data));
@ibc
Copy link
Member

ibc commented Nov 13, 2012

Right, for now JsSIP ignores WebSocket binary messages. Does your suggested code convert the received binary data into a real JS string that can be later parsed by JsSIP SIP parser?

BTW when JavaScript receives a WS "binary" message it calls onmessage(data), and such data is:

  • Blob (in case WebSocket binaryType attribute is set to "blob", which is the default value).
  • ArrayBuffer (in case WebSocket binaryType attribute is set to "arraybuffer").

It seems that using ArrayBuffer is more efficient in case the data will be managed in memory (rather than storing in disk).

Which mode should JsSIP use for binary data? which one will work with your suggested code?

Thanks a lot!

@vf1
Copy link
Author

vf1 commented Nov 13, 2012

Yes, it is convert. But I did not test it w/ non-ascii symbols.

I did not change anything else. But connect function already has mode selection.

  /**
  * Connect socket.
  */
  connect: function() {
    var transport = this;

    ....

    this.ws.binaryType = 'arraybuffer';

PS. Actually, I am not js developer.

@ibc
Copy link
Member

ibc commented Nov 13, 2012

Ok, I will test it by sending a WebSocket binary message to JsSIP after implementing your code, let me sometime to do it. Thanks a lot.

@ibc ibc closed this as completed in 11c6bb6 Nov 13, 2012
@ibc
Copy link
Member

ibc commented Nov 13, 2012

It works, commited. Thanks a lot!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants