TsgcWSPClient_Presence › Events › OnPublishMsg
Fires when a Publish message is received on a channel.
property OnPublishMsg: TsgcWSPresencePublishMsgEvent;
// TsgcWSPresencePublishMsgEvent = procedure(Connection: TsgcWSConnection; const aMsg: TsgcWSPresenceMsg; const aChannel: TsgcWSPresenceChannel; const aMember: TsgcWSPresenceMember) of object
—
Fires on every subscriber of aChannel when another member calls Publish. aMsg carries the payload (aMsg.Text) and message type, aMember identifies the sender. This is the main hook to display chat or channel messages in the UI.
procedure TForm1.oPresencePublishMsg(Connection: TsgcWSConnection;
const aMsg: TsgcWSPresenceMsg; const aChannel: TsgcWSPresenceChannel;
const aMember: TsgcWSPresenceMember);
begin
Memo1.Lines.Add(Format('[%s] %s: %s',
[aChannel.Name, aMember.Name, aMsg.Text]));
end;