Protocol
WAMP
Web Application Messaging Protocol
WAMP is an open standard WebSocket subprotocol that provides two application messaging patterns in one unified protocol: Remote Procedure Calls + Publish & Subscribe.

Remote Procedure Call (RPC)

A Caller issues calls to remote procedures by providing the procedure URI and any arguments for the call. The Callee will execute the procedure using the supplied arguments to the call and return the result of the call to the Caller.

PubSub

A Publishers publishes events to topics by providing the topic URI and any payload for the event. Subscribers of the topic will receive the event together with the event payload.
Subscribers subscribe to topics they are interested in with Brokers. Publishers initiate publication first at Brokers. Brokers route events incoming from Publishers to Subscribers that are subscribed to respective topics.

Create Connection

// Create websocket client and set server options
oClient := TsgcWebSocketClient.Create(nil);
oClient.Host := '';
oClient.Port := 80;

// Create WAMP protocol and assign to websocket client
oWAMP := TsgcWSPClient_WAMP2.Create(nil);
oWAMP.Client := oClient;

// Handle WAMP methods
oWAMP.OnWAMPWelcome := OnWAMPWelcomeHandler;
oWAMP.OnWAMPGoodBye := OnWAMPGoodByeHandler;

// connect to server
oClient.Active := True;

Subscribe

// Subscribe to channel "myTopic"
oWAMP.Subscribe('myTopic');

Publish

// Send a message to all subscribers of channel "myTopic"
oWAMP.Publish('myTopic', 'Text message');

Supported Platforms

The component supports the following Platforms:

Delphi   CBuilder Lazarus