SignalR Core Delphi

· Componenti

 ASP.NET Core SignalR è an open-source libreria che simplifies aggiungendo real-time web functionality a apps. Real-time web functionality abilita server-side codice a push content a client instantly.

Good candidates per SignalR:


SignalR Core sgcWebSockets componente utilizza WebSocket come transport a connetti a un SignalR Core server, se questo transport è non supportati, an errore essere raised. 

Delphi Esempio di codices 

SignalRCore.Invoke('SendMessage', ['John', 'Hello All.'], 'id-000001');
procedure OnSignalRCoreCompletion(Sender: TObject; Completion: TSignalRCore_Completion);
begin
  se Completion.Error <> '' then
    ShowMessage('Something goes wrong.')
  else
    ShowMessage('Invocation Successful!');
end; 

Invocations: il Caller invia a messaggio a il Callee e expects a messaggio indicating che il invocation ha been completed e facoltativoly a result di il invocation

Example: client invokes SendMessage metodo e passes come parametri utente name e text message. Invia an Invocation Id a ottenere a result messaggio da il server. 

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

Non-Blocking Invocations: il Caller invia a messaggio a il Callee e does non expect qualsiasi further messaggi per questo invocation. Invocations può essere inviato senza an Invocation ID value. Questo indicates che il invocation è "non-blocking".

Example: client invokes SendMessage metodo e passes come parametri utente name e text message. Il client non expect qualsiasi risposta da il server riguardo a il result di il 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
  se Completion.Error <> '' then
    ShowMessage('Something goes wrong.')
  else
    ShowMessage('Invocation Successful!');
end; 

Streaming Invocations: il Caller invia a messaggio a il Callee e expects uno o more results restituito da il Callee followed da un messaggio indicating il end di invocation.

Example: client invokes Counter metodo e richieste 10 numbers con an interval di 500 milliseconds.