TsgcWSPClient_PresenceEvents › OnPublishMsg

OnPublishMsg Event

Fires when a Publish message is received on a channel.

Syntax

property OnPublishMsg: TsgcWSPresencePublishMsgEvent;
// TsgcWSPresencePublishMsgEvent = procedure(Connection: TsgcWSConnection; const aMsg: TsgcWSPresenceMsg; const aChannel: TsgcWSPresenceChannel; const aMember: TsgcWSPresenceMember) of object

Default Value

Remarks

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.

Example

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;

Back to Events