WAMP Protocol

Web Application Messaging Protocol — unified Remote Procedure Calls (RPC) and Publish/Subscribe (PubSub) in a single protocol over WebSocket.

What is WAMP?

WAMP combines two core messaging patterns — RPC and PubSub — into a single, unified protocol running over WebSocket.

Unified RPC and PubSub

Most real-time applications need both request-response (RPC) and event notification (PubSub) patterns. WAMP provides both in a single protocol, eliminating the need to combine multiple messaging systems. A WAMP router manages realms (isolation domains) and sessions, routing procedure calls to callees and events to subscribers. sgcWebSockets implements the WAMP Basic and Advanced profiles, supporting authentication, progressive results, and caller/callee identification.

  • RPC and PubSub in a single protocol
  • Router-based architecture for scalability
  • Realm-based isolation for multi-tenancy
  • Runs natively over WebSocket connections
ROUTER CALLER CALLEE SUB RPC PubSub

WAMP Features

Two messaging patterns, one protocol, infinite possibilities.

Remote Procedure Calls

Register procedures on one client and call them from another. The WAMP router handles routing, load balancing, and result delivery.

Publish/Subscribe

Subscribe to topics and receive real-time events. Publishers and subscribers are fully decoupled through the WAMP router.

Router-Based Architecture

A central WAMP router manages all message routing, enabling clean separation between application components.

Realms & Sessions

Realms provide isolation domains for multi-tenant applications. Sessions manage client lifecycle within realms.

Authentication

Built-in support for ticket-based authentication and Challenge-Response Authentication (CRA) for secure session establishment.

Progressive Results

Long-running RPC calls can return intermediate results progressively, keeping clients informed during processing.

Caller/Callee Identification

Optionally identify the caller when making RPC calls, enabling authorization and auditing at the application level.

WAMP Use Cases

Applications that benefit from unified RPC and PubSub messaging.

Real-Time Dashboards

Build live dashboards that receive real-time data updates via PubSub and fetch on-demand data through RPC calls.

Collaborative Editing

Enable real-time collaborative document editing with PubSub for change notifications and RPC for conflict resolution.

Microservices Orchestration

Orchestrate microservices with RPC for service-to-service calls and PubSub for event-driven communication.

IoT Device Management

Manage IoT devices with RPC for command execution and PubSub for telemetry data streaming.

Gaming Backends

Build game backends with RPC for game actions and PubSub for real-time game state broadcasts to all players.

Delphi WAMP Example

Connect to a WAMP router, register procedures, and subscribe to topics.

uses
  sgcWebSocket_Client, sgcWebSocket_Types;

var
  WSClient: TsgcWebSocketClient;

procedure TForm1.FormCreate(Sender: TObject);
begin
  WSClient := TsgcWebSocketClient.Create(nil);
  WSClient.Host := 'router.example.com';
  WSClient.Port := 8080;

  // Enable WAMP protocol
  WSClient.WAMP.Enabled := True;
  WSClient.WAMP.Realm := 'myapp';

  // Set up event handlers
  WSClient.OnWAMPWelcome := OnWAMPWelcome;
  WSClient.OnWAMPEvent := OnWAMPEvent;
  WSClient.OnWAMPResult := OnWAMPResult;
end;

procedure TForm1.ButtonConnectClick(Sender: TObject);
begin
  WSClient.Active := True;
end;

procedure TForm1.OnWAMPWelcome(Sender: TObject;
  aSession: Int64);
begin
  // Subscribe to a topic
  WSClient.WAMP.Subscribe('com.myapp.updates');

  // Register a procedure that others can call
  WSClient.WAMP.&Register('com.myapp.getStatus');
end;

procedure TForm1.OnWAMPEvent(Sender: TObject;
  aSubscriptionId: Int64; aTopic, aDetails: string);
begin
  // Handle PubSub events
  Memo1.Lines.Add('Event: ' + aTopic + ' - ' + aDetails);
end;

procedure TForm1.ButtonCallClick(Sender: TObject);
begin
  // Call a remote procedure
  WSClient.WAMP.Call('com.myapp.calculate',
    '[42, 58]');
end;

procedure TForm1.ButtonPublishClick(Sender: TObject);
begin
  // Publish an event to a topic
  WSClient.WAMP.Publish('com.myapp.updates',
    '{"type": "status", "value": "online"}');
end;

Documentation & Demos

Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.

Ready to Get Started with WAMP?

Download the free trial and build real-time applications with unified RPC and PubSub.