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

Android - Binary data support (send only) #54

Open
shblythe opened this issue Jun 30, 2014 · 2 comments
Open

Android - Binary data support (send only) #54

shblythe opened this issue Jun 30, 2014 · 2 comments
Labels
Milestone

Comments

@shblythe
Copy link

This is related to issue #53 where the same was requested for iOS.

(I don't know if the user who raised that issue also wanted receive support, but in my application I only need to send binary data).

I propose addition of a new method:

sendBinary(successCallback, errorCallback, connectionId, data)

In this case data is a JSONArray, one byte per element, so it may be called as follows:

window.tlantic.plugins.socket.sendBinary(
  function() {
    console.log('sent')
  },
  function(error) {
    console.log('failed to send: '+error)
  },
  connectionId,
  [ 0x01, 0x00, 0x01, 0xFD ]
);
@vinnylinck
Copy link

Thank you!

On 30/06/2014, at 17:29, shblythe notifications@github.com wrote:

This is related to issue #53 where the same was requested for iOS.

(I don't know if the user who raised that issue also wanted receive support, but in my application I only need to send binary data).

I propose addition of a new method:

sendBinary(successCallback, errorCallback, connectionId, data)
In this case data is a JSONArray, one byte per element, so it may be called as follows:

window.tlantic.plugins.socket.sendBinary(
function() {
console.log('sent')
},
function(error) {
console.log('failed to send: '+error)
},
connectionId,
[ 0x01, 0x00, 0x01, 0xFD ]
);

Reply to this email directly or view it on GitHub.

shblythe added a commit to shblythe/cdv-socket-plugin that referenced this issue Jun 30, 2014
(Implemented for Android only)

Interface is:
sendBinary(successCallback, errorCallback, connectionId, data)

data is a JSONArray, one element per byte, e.g. [ 0x00, 0x01, 0x00, 0xFD ]
@thomasbrueggemann
Copy link

Wouln't something like this work too?

var arraydata = [77, 67, 71, 80];
var stringdata = String.fromCharCode.apply(null, arraydata);

window.tlantic.plugins.socket.sendBinary(
  function() {
    console.log('sent')
  },
  function(error) {
    console.log('failed to send: '+error)
  },
  connectionId,
  stringdata
);

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

No branches or pull requests

4 participants