SignalR Core Delphi

 ASP.NET Core SignalR is an open-source library that simplifies adding real-time web functionality to apps. Real-time web functionality enables server-side code to push content to clients instantly.

Good candidates for SignalR:

      • Apps that require high-frequency updates from the server. Examples are gaming, social networks, voting, auction, maps, and GPS apps.
  • Dashboards and monitoring apps. Examples include company dashboards, instant sales updates, or travel alerts.
  • Collaborative apps. Whiteboard apps and team meeting software are examples of collaborative apps.
  • Apps that require notifications. Social networks, email, chat, games, travel alerts, and many other apps use notifications.

SignalR Core sgcWebSockets component uses WebSocket as transport to connect to a SignalR Core server, if this transport is not supported, an error will be raised. 

Delphi Code Examples 

SignalRCore.Invoke('SendMessage', ['John', 'Hello All.'], 'id-000001');

procedure OnSignalRCoreCompletion(Sender: TObject; Completion: TSignalRCore_Completion);
begin
  if Completion.Error <> '' then
    ShowMessage('Something goes wrong.')
  else
    ShowMessage('Invocation Successful!');
end; 

Invocations: the Caller sends a message to the Callee and expects a message indicating that the invocation has been completed and optionally a result of the invocation

Example: client invokes SendMessage method and passes as parameters user name and text message. Sends an Invocation Id to get a result message from the server. 

SignalRCore.Invoke('SendMessage', ['John', 'Hello All.']); 

Non-Blocking Invocations: the Caller sends a message to the Callee and does not expect any further messages for this invocation. Invocations can be sent without an Invocation ID value. This indicates that the invocation is "non-blocking".

Example: client invokes SendMessage method and passes as parameters user name and text message. The client doesn't expect any response from the server about the result of the invocation. 

SignalRCore.InvokeStream('Counter', [10, 500], 'id-000002');

procedure OnSignalRCoreStreamItem(Sender: TObject; StreamItem: TSignalRCore_StreamItem; var Cancel: Boolean);
begin
  DoLog('#stream item: ' + StreamItem.Item);
end;

procedure OnSignalRCoreCompletion(Sender: TObject; Completion: TSignalRCore_Completion);
begin
  if Completion.Error <> '' then
    ShowMessage('Something goes wrong.')
  else
    ShowMessage('Invocation Successful!');
end; 

Streaming Invocations: the Caller sends a message to the Callee and expects one or more results returned by the Callee followed by a message indicating the end of invocation.

Example: client invokes Counter method and requests 10 numbers with an interval of 500 milliseconds.

×
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

Kensington Verimark Fingerprint Review
Obsolete Connection String using RSA

Related Posts