Anonymous User
  Monday, 06 March 2023
  3 Replies
  688 Visits

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?
1 year ago

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

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,

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

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,
  • Page :
  • 1
There are no replies made for this post yet.
Submit Your Response
Upload files or images for this discussion by clicking on the upload button below.
Supported: gif,jpg,png,jpeg,zip,rar,pdf
· Insert · Remove
  Upload Files (Maximum 10MB)