You are not logged in.
Pages: 1
Hi Arnaud,
I'm new to WebSockets and I'm lost in the great amount of classes defined in SynBidirSock.pas
I want to do something using the client class like the following (taken from https://github.com/andremussche/DelphiWebsockets):
client := TIdHTTPWebsocketClient.Create(Self);
client.Port := 12345;
client.Host := 'localhost';
client.SocketIOCompatible := True;
client.SocketIO.OnEvent(C_SERVER_EVENT,
procedure(const ASocket: ISocketIOContext; const aArgument: TSuperArray; const aCallback: ISocketIOCallback)
begin
ShowMessageInMainthread('Data PUSHED from server: ' + aArgument[0].AsJSon);
//server wants a response?
if aCallback <> nil then
aCallback.SendResponse('thank for the push!');
end);
client.Connect;
client.SocketIO.Emit(C_CLIENT_EVENT, SO([ 'request', 'some data']),
//provide callback
procedure(const ASocket: ISocketIOContext; const aJSON: ISuperObject; const aCallback: ISocketIOCallback)
begin
//show response (threadsafe)
ShowMessageInMainthread('RESPONSE: ' + aJSON.AsJSon);
end);
Which class in the mORMot framework I should use? I guess its
THttpClientWebSockets
?
And How to send and receive JSON data? Thanks.
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
Why do you want to use TIdHTTPWebsocketClient ?
I do not understand your problem.
Did you take a look at the documentation, and the samples?
See http://synopse.info/files/html/Synopse% … l#TITL_150
and https://github.com/synopse/mORMot/tree/ … WebSockets
Offline
Hi ab,
I need to communicate with the Chrome browser via WebSockets: https://developer.chrome.com/devtools/d … r-protocol
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
See the first sample detailed in the doc.
https://github.com/synopse/mORMot/blob/ … Server.dpr
There is a html page to work with a browser as a client
https://github.com/synopse/mORMot/blob/ … erver.html
Offline
Thanks ab, so I'm trying THttpClientWebSockets, according your latest reply it seems that I'm not using the correct class, so will try TWebSocketServer now...
You can ignore my current testing result: using THttpClientWebSockets:
var
myStr: string;
begin
if Assigned(FWSCli) then
FWSCli.Free;
//FWSCli := TSQLHttpClientWebsockets.Create(cSvrAddr, cCefDebugPort, TSQLModel.Create([])); //same error.
FWSCli := THttpClientWebSockets.Open(cSvrAddr, cCefDebugPort);
FWSCli.Settings.SetFullLog;
myStr := FWSCli.WebSocketsUpgrade('ws://localhost:9289/someUri', '', True, True);
LogIt('WebSocketsUpgrade result: ' + myStr);
Result:
WebSocketsUpgrade result: Invalid HTTP Upgrade Header
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
It is so strange, there is a class named TWebSocketServer, but no class TWebSocketClient.
the client demo is a html page, but i want write client with delphi, how?
Offline
i guess it is, but i don't known how to use it .
Offline
i guess it is, but i don't known how to use it .
Offline
Pages: 1