TsgcWSPServer_Presence › Events › OnBeforePublishMsg
Fired before a client-published message is relayed; set Accept to False to drop it.
property OnBeforePublishMsg: TsgcWSPresenceBeforePublishMsgEvent;
// TsgcWSPresenceBeforePublishMsgEvent = procedure(Connection: TsgcWSConnection; const aMsg: TsgcWSPresenceMsg; const aChannel: TsgcWSPresenceChannel; const aMember: TsgcWSPresenceMember; var Accept: Boolean) of object
—
Called when a member publishes a message to a channel. The server can inspect the payload, the source member, and the target channel, and decide whether to forward it to the channel subscribers by setting Accept. If Accept is False the server raises OnErrorPublishMsg on the publisher.
procedure TForm1.sgcWSPServer_Presence1BeforePublishMsg(Connection: TsgcWSConnection;
const aMsg: TsgcWSPresenceMsg; const aChannel: TsgcWSPresenceChannel;
const aMember: TsgcWSPresenceMember; var Accept: Boolean);
begin
if Pos('spam', LowerCase(aMsg.Text)) > 0 then
Accept := False;
end;