Hello
I use events and i send them to multiple clients, but now i need send event to a particular client only. Is it any way to send this event, only to one client?
Renata
Hello
I use events and i send them to multiple clients, but now i need send event to a particular client only. Is it any way to send this event, only to one client?
Renata
you need to specify his session ID in SessionList
of event sink.
lets use the SuperHTTP Chat
sample as an example
procedure TChatServerService.TalkPrivate(const TargetNickname: AnsiString; const Message: AnsiString);
var
ev: IChatEvents_Writer;
begin
if ServerForm.UserExists(TargetNickname) then begin
ev := EventRepository as IChatEvents_Writer;
ev.ExcludeSender := true;
ev.ExcludeSessionList := false;
ev.SessionList.Add(ServerForm.UserSession(TargetNickname)); ///<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
ev.Message(Session.SessionID, {$IFDEF UNICODE}WideStringToAnsiString{$ENDIF}(Session.Values[NICKNAME_ID]), TargetNickname, Message);
end;
end;
Many thanks for your answer, I did it as you suggested and it works correctly now.
I really appreciate your quick reaction.
Renata