1

Is it possible to send byte data (array) over Websockets or only strings?

So any ideas why ArrayBuffer doesnt work?

Thanks in advance.

2 Answers 2

1

The API isn't finalized, but you should be able to use an ArrayBuffer (a JavaScript typed array).

Sign up to request clarification or add additional context in comments.

3 Comments

How to add 1 byte to ArrayBuffer? arr[i] = 128; puts in array "128"(0x31 0x32 0x38). arr[i].push(128); same.
What browser? arr[i] seems to work fine in Chrome 15. At any rate, as described on the JavaScript typed arrays page, you should probably be working with a view, and not the raw array. But this is really a separate issue from your original question, so you should ask a separate question if you're having trouble.
sockets.push(new WebSocket("ws://"+serverip+":"+serverport)); sendbuf[id] = new ArrayBuffer(); sendbuf[id][0] = 128; sockets[id].send(sendbuf[id]); This send "128" not 128; (Chrome)
1

Yes. Blob objects claim to offer this functionality, but they're only supported on a few browsers to my understanding.

https://developer.mozilla.org/en/WebSockets/WebSockets_reference/WebSocket

https://developer.mozilla.org/en/DOM/Blob

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.