Hello,
I started with the websocket demo and I am trying to make a websocket connection to our own software.
So I have made sure that the websocket is created in the following way:
URL:='ws://'+aHost+':5001/ws/';
end;
try
WS:=TJSWebsocket.New(url,'csr');
ws.binaryType:='arraybuffer';
WS.onopen:=@DoOpen;
WS.onmessage:=@DoIncomingMessage;
WS.onclose:=@DoClosed;
The connection is made and I receive a message from out software. In the DoIncomingMessage event I try to handle the received data.
This should be an ArrayBuffer. And I try to handle this in the following way. Only myarray remains an array with a length of 0. So obviously I am doing something wrong. Does someone know what it is I am doing wrong? And the next question how do I cast the byte array to a string?
var
mystring: string;
myarray:TJSUint8Array;
begin
myarray := TJSUint8Array.new(TJSUint8Array.from(Msg.Data));
mystring := myarray.toLocaleString;
Writeln(mystring);
end;