Send Messages from Server to Client(s)
GitHubDelphi opened this issue · 2 comments
GitHubDelphi commented
My use case is to push messages (based on events) from the server to one or more clients directly - without the need for a client request.
What is the preferred way of accomplishing this behaviour?
andremussche commented
To send to one: use the "OnConnection" event
FHttpServer.SocketIO.OnConnection(
procedure(const ASocket: ISocketIOContext)
begin
ASocket.EmitEvent(C_SERVER_EVENT, SO(['data', 'pushed from server to
only you']);
end);
To send to all: use the "EmitEventToAll"
server.SocketIO.EmitEventToAll(C_SERVER_EVENT, SO(['data', 'pushed from
server to all']),
2016-12-06 1:08 GMT+01:00 GitHubDelphi <notifications@github.com>:
… My use case is for the server to send messages to either a single, or all
clients.
What is the preferred way of accomplishing this behaviour?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#17>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AC5IjuqP-hh0k0nwjeW8lPAdKxJl4tmPks5rFKdsgaJpZM4LE3uD>
.
MCSTN commented
Any clues on WS_Server.SocketIO.EmitEventTo() usage to emit to single client?
I do understand usage of WS_Server.SocketIO.EmitEventToAll() but can't figure out the .EmitEventTo() usage.
Guessing AContext parameter is used to specify the client to send to but how? I'm lost. Anybody?