A subscriber receives events by first providing topics (aka channels) he is interested. Subsequently, the subscriber will receive any events publishes to that topic.
To receive events from a topic, first has to subscribe to this topic.
WAMP Client
procedure OnMessageEvent(Connection: TsgcWSConnection; const Text: string);
begin
ShowMessage(Text);
end;
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;
// Subscribe to topic after successful connect
oClient.Subscribe('myTopic');
WAMP Server
procedure OnSubscriptionEvent(Connection: TsgcWSConnection; const Subscription: string);
begin
ShowMessage('Subscribed: ' + Subscription);
end;
oServer := TsgcWebSocketServer.Create(nil);
oServer.Port := 80;
oServerWAMP := TsgcWSPServer_WAMP.Create(nil);
oServerWAMP.OnSubscription := OnSubscriptionEvent;
oServerWAMP.Server := oServer;
oServerWAMP.Active := True;