By Guest on Monday, 06 March 2023
Posted in General
Replies 3
Likes 0
Views 0.9K
Votes 0
hello,

I'm going to evaluate the component set to create a signalR client for a hub, and I have a few questions:

1. Is there an option on to reconnect automatically to the hub on connection lost?
2. I have seen that the call to a method of the hub contains a JSON object with Hub, Method and method parameters in the format {"H":"simplehub","M":"JoinGroup","A":["%s"],"I":2}. Is there any compatibility issue when the method parameters are a JSON object?
3. If the client side must only process messages from some methods, how runst the method subscription? Is there any way to implemtn hooks on client side for each method notification?
Hello,

1. The TsgcWebSocketClient has the WatchDog property that allows to reconnect automatically if detects a disconnection.

https://www.esegece.com/help/sgcWebSockets/#t=Topics%2FFeatures%2FWatchDog.htm
https://www.esegece.com/help/sgcWebSockets/#t=Components%2FTsgcWebSocketClient%2FConnection%2FClient_Keep_Connection_Open.htm

2. No, the SignalR client just sends the JSON message though the websocket protocol, there is no transformation, so if the JSON message is correct it's ok.
3. The subscription message depends of the SignalR server. SignalR makes use of the following message format:

{"H":"chathub","M":"Send","A":["Delphi Client","Test message"],"I":0}

Where every node means the following:

I – invocation identifier – allows to match up responses with requests
H – the name of the hub
M – the name of the method
A – arguments (an array, can be empty if the method does not have any parameters)

Most probably, to subscribe, you must send a method with the name of subscription and the arguments if needed.

Kind Regards,
Sergio
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,

First, thank you for the quick reply.

About the reply of the second point means that when writing {"H":"simplehub","M":"JoinGroup","A":["%s"],"I":2}, and %s it is a JSON object, there will be no problem to invoke the method JoinGroup?

Best regards
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,

Not tested, but if the argument is a JSON object, most probably requires to escape the JSON text. Example: if the json object is


{"name": "value"}


The SignalR message should be something link this:


{"H":"simplehub","M":"JoinGroup","A":["{\"name\": \"value\"}"],"I":2}


Kind Regards,
Sergio
·
1 year ago
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post