Repository navigation
websocket onMessage data type #15049
Replies: 2 comments
|
Yes. A WebSocket message is a text or binary frame; it does not preserve the JavaScript class passed to If you prefer |
|
The WebSocket wire format doesn't carry any JS type info. On the client, a TypedArray, DataView or Blob all get flattened to raw bytes before going on the wire, so the server just sees a binary frame. That's why everything arrives as ArrayBuffer regardless of what you sent. If you need the original type back, you have to tag it yourself. I usually prepend a single byte header, or send a small JSON text message describing the next binary frame. You can also set — |
Uh oh!
There was an error while loading. Please reload this page.
Dear All,
So far i use websocket to send string from client to server is fine,
And recently, I just try send data from Client with data type other than string i.e. ArrayBuffer, Blob, TypedArray and DataView.
However, when i check in data received in server (Deno websocket) was only ArrayBuffer or its having different type from Client, except ArrayBuffer its self.
My question is, whether it is the default of Deno.websocket if the data type received from Client is only String and ArrayBuffer instead any data type?
All reactions