Websocket client


i try to connect to a websocket server , send message and get response;


procedure Tfmain.WebButton1Click(Sender: TObject);
begin
fmain.websock.HostName := str_hostname ;
fmain.websock.Port := int_port;
fmain.websock.Connect;
end;

procedure Tfmain.websockConnect(Sender: TObject);
begin
fmain.pnlmain.Caption := 'connected'; 
end;


procedure Tfmain.websockDataReceived(Sender: TObject; Origin: string;
Data: TJSObject);
begin
fmain.pnltop.Caption := data.toString;
end;


on datareceived i get this error :

ERROR
Unable to get property 'toString' of undefined or null reference | TypeError: Unable to get property 'toString' of undefined or null reference at websockDataReceived (http://localhost:8000/padd/padd.js:28472:7) at cb (http://localhost:8000/padd/padd.js:222:9) at DoMessage (http://localhost:8000/padd/padd.js:28308:63) at me.FWebSocket.onmessage (http://localhost:8000/padd/padd.js:28389:17)
at http://localhost:8000/padd/padd.js [28472:7]


webcokect client,

i can connect, i can send message, but i get error on datareceived

Thanks for reporting. We traced & solved this issue and can confirm the next update will address this.

Hi, same issue now for last beta WEB CORE 1.6 and DELPHI 10.4
Websocket client error on datareceived in CHAT demo.
websocket server is working and i can receive the broadcasted message in a test webclient extenxione in chrome.

I modify a little the code from demo TMSweb_client in uCLIENT.pas as follow :

procedure TForm43.WebSocketClient1DataReceived(Sender: TObject; Origin: string;
SocketData: TJSObjectRecord);
var
jo: TJSObject;
s: string;

it: TTMSFNCListBoxItem;
sl: TStringList;

n: string;
v: string;
begin
lst.BeginUpdate;
it := lst.Items.Add;
jo := socketData.jsobject;
s := jo.toString;
sl := TStringList.Create;
try
TTMSFNCUtils.Split('~', s, sl);
if sl.Count > 2 then
begin
n := ''+sl[1];
v := sl[2];
it.Text := n + ' says: ' + v+'';
end;
finally
sl.Free;
end;
lst.EndUpdate;
end;

this is the browser error

ERROR
TypeError: jo is null | this.WebSocketClient1DataReceived@http://localhost:8000/TMSWeb_ChatClient/TMSWeb_ChatClient.js:94237:7 cb@http://localhost:8000/TMSWeb_ChatClient/TMSWeb_ChatClient.js:242:19 this.DoMessage@http://localhost:8000/TMSWeb_ChatClient/TMSWeb_ChatClient.js:41110:14 this.Connect/me.FWebSocket.onmessage@http://localhost:8000/TMSWeb_ChatClient/TMSWeb_ChatClient.js:41192:20
at http://localhost:8000/TMSWeb_ChatClient/TMSWeb_ChatClient.js [94237:7]

Not sure why this is happening.
What do you see in the browser console when you add
console.log(SocketData);
console.log(SocketData.jsobject);
?

console.log(SocketData);
VM210:1 {jsobject: null}
undefined

We traced & solved this issue. The next update will address this.