WAMP | 发布者

发布者通过提供主题(即频道)作为抽象地址而非具体对端来发布事件。只需调用 Publish 方法,并将主题名称和要发送的消息作为参数传入,该消息将被投递给该主题的所有订阅者。请注意,向某主题发布消息无需事先订阅该主题。

 

无需在服务器端配置任何内容,因为当收到发布消息时,消息会自动广播给客户端。

 

WAMP 客户端

 


oClient := TsgcWebSocketClient.Create(nil);
oClient.Host := '127.0.0.1';
oClient.Port := 80;
oClientWAMP := TsgcWSPClient_WAMP.Create(nil);
oClientWAMP.Client := oClient.
oClientWAMP.OnMessage := OnMessageEvent;
oClient.Active := True;
 
// Publish a message to all subscribers
oClient.Publish('myTopic', 'Hello subscribers myTopic');