Jump to content
Sign in to follow this  
Flemming

Send binary stream with WebSocket

Recommended Posts

according to the API...

https://developer.mozilla.org/en-US/docs/Web/API/WebSocket

...the send() method can send a string, Blob, or ArrayBuffer

 

So you could try to use JBlob or JArrayBuffer (from lib.Core.pas)

 

And there is something with JWebsocket.binaryType you can do:

http://stackoverflow.com/questions/9462879/how-do-i-tell-the-type-of-websocket-onmessages-parameter

Share this post


Link to post
Share on other sites

I have made a copy from lib.Core and renamed part of it. I have tried to create a ArrayBuffer with UInt8Array.set and UInt8Array.new but it doesent compile through the creation ?

 

 
procedure TFmClient.Bt_SendBinaryClick(Sender: TObject); 
var 
  n  : Integer; 
  A  : array of integer; 

  ArrayBuffer : JArrayBuffer2; 
  UInt8       : JUInt8Array2; 
  BufferView  : JArrayBufferView2; 
  UInt8_Core  : JUint8Array_Core; 
begin 
// ws.binaryType:='ArrayBuffer'; 

  A.SetLength(8); 
  for n:=0 to 7 do A[n]:=n; 
  UInt8.Set(A,0); 
  UInt8_Core.new(A); 

  memo1.text:='Done '; 
end; 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×