<!-- Add to your HTML --><scriptsrc="web-agent.libs.js"></script><scriptsrc="web-agent.js"></script><!-- Optional: For WebRTC (video/audio/screen sharing) --><scriptsrc="web-agent.webrtc.js"></script>
The Messaging Platform is a real-time communication system that enables agents (clients) to exchange messages through channels.
It supports multiple protocols (HTTP, WebSocket, UDP) and provides features like encryption, WebRTC relay, channel isolation, and ephemeral messaging.
The system includes a DB Persistence Layer for session management and a Caching Layer for high-performance operations.
๐ HIGH-LEVEL ARCHITECTURE
๐ API Key System
The platform uses a flexible API key system with two types of keys for different security requirements.
Original API Key vs Temporary API Key
๐ API KEY ARCHITECTURE
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ API KEY SYSTEM โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ ORIGINAL API KEY (Developer Key) โ
โ โโโ Permanent key issued to developer โ
โ โโโ Full access to all features โ
โ โโโ Used for server-side applications โ
โ โโโ Should be kept SECRET (never expose to clients) โ
โ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ TEMPORARY KEY SERVICE โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ โข Creates short-lived keys from original key โ โ โ
โ โ โ โข Sets expiration time (e.g., 1 hour, 24 hours) โ โ โ
โ โ โ โข Restricts capabilities (read-only, specific events) โ โ โ
โ โ โ โข Limits to specific agent names โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ TEMPORARY API KEY (Client Key) โ
โ โโโ Short-lived (expires automatically) โ
โ โโโ Limited capabilities โ
โ โโโ Safe for client-side applications โ
โ โโโ If compromised, expires soon anyway โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ก WHEN TO USE EACH:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Original API Key โ Temporary API Key โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ Server-side applications โ โ Web browsers (JavaScript) โ
โ โ Backend services โ โ Mobile apps โ
โ โ Trusted environments โ โ Untrusted clients โ
โ โ Full feature access needed โ โ Limited feature access OK โ
โ โ Never in client-side code โ โ Safe to expose in client code โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Temporary Key Flow
1
Server Creates Temporary Key
Your backend server uses the original API key to create a temporary key with specific restrictions.
2
Client Receives Temporary Key
The temporary key is sent to the client (browser, mobile app). It's safe to transmit over the network.
3
Client Connects to Channel
The client uses the temporary key to connect. The platform validates it and applies restrictions.
4
Key Expires Automatically
After the expiration time, the key stops working. Client needs a new temporary key to continue.
๐ API Key Scope - Channel Isolation
The apiKeyScope parameter controls how channels are isolated between different developers.
This is crucial for both security (production) and convenience (testing).
๐ PRIVATE SCOPE (Default) - Channel Isolation
๐ API Key Scope - Shared Channels
The apiKeyScope parameter controls how channels are isolated between different developers.
This is crucial for both security (production) and convenience (testing).
๐ PUBLIC SCOPE - Shared Channels
When to Use Each Scope
๐ Private Scope (Default)
Production applications
Multi-tenant systems
When user data must be isolated
Billing/metering per developer
Security-sensitive applications
๐ Public Scope
Testing with teammates
SDK examples and demos
Cross-developer collaboration
Public game lobbies
Community features
๐ก Connection & Message Flow
Understanding how agents connect and exchange messages through the platform.
๐ CONNECTION FLOW
๐ฆ Three-Layer Messaging Architecture
The platform uses a sophisticated three-layer storage system to optimize message delivery for different use cases.
Messages flow through Cache for instant access, Kafka for reliable message brokering,
and Database for permanent persistence.
๐๏ธ MESSAGE STORAGE LAYERS
๐ค Message Send Flow
When an agent sends a regular (persistent) message, it flows through all three layers:
1
Message Sent to Service
Agent sends message via HTTP/WebSocket/UDP to the messaging service.
2
Written to Cache
Message is immediately cached in memory for fast access. Limited retention time (TTL-based).
3
Published to Kafka
Message is published to Kafka for reliable delivery and event streaming. Has retention limits (not permanent).
4
Persisted to Database
Message is saved to the database for permanent storage, structured querying, and long-term audit trails.
๐ฅ Message Receive with pollSource
The pollSource parameter lets you control which layer(s) to read from. This is crucial for optimizing performance based on your use case.
๐ฏ pollSource OPTIONS
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ pollSource VALUES โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ AUTO (Default - Recommended) โ
โ โโโ Tries all layers in order: Cache โ Kafka โ Database โ
โ โโโ Falls back automatically if a layer has no data โ
โ โโโ Best for: General purpose, balanced performance โ
โ โโโ ๐ก Smartly optimizes between speed and completeness โ
โ โ
โ CACHE (Ultra-Fast Mode) โ
โ โโโ Reads ONLY from in-memory cache โ
โ โโโ Fastest possible response time (< 1ms typical) โ
โ โโโ Best for: Real-time gaming, live updates, high-frequency polling โ
โ โโโ โ ๏ธ Warning: May miss messages not yet cached or already expired โ
โ โโโ ๐ฎ Use case: Air Hockey game, cursor tracking, live player positions โ
โ โ
โ KAFKA (Message Broker Mode) โ
โ โโโ Reads ONLY from Kafka message broker โ
โ โโโ Access to recent message stream (has retention limits) โ
โ โโโ Best for: Event streaming, real-time delivery, recent history โ
โ โโโ โ ๏ธ Note: Not permanent - messages expire after retention period โ
โ โโโ ๐จ Use case: Live event streaming, recent message replay โ
โ โ
โ DATABASE (Permanent Storage Mode) โ
โ โโโ Reads ONLY from database (permanent storage) โ
โ โโโ Access to complete, permanent message history โ
โ โโโ Best for: Audit trails, compliance, historical queries, analytics โ
โ โโโ โพ๏ธ Source of truth - messages stored permanently โ
โ โโโ ๐ Use case: Compliance reporting, audit logs, data analysis โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ก HOW TO USE pollSource:JavaScript:
agent.connect({
channelName: 'game-room',
channelPassword: 'secret',
agentName: 'Player-1',
pollSource: 'CACHE' // Set default for all receives
});
// All receives use CACHE automatically
agent.receive(range); // Uses CACHE
// Override per-request if needed
agent.receive({...range, pollSource: 'KAFKA'});
Python:
agent.connect(
channel_name='game-room',
channel_password='secret',
agent_name='Player-1',
poll_source='CACHE' # Set default
)
# Receives use CACHE by default
agent.receive(session_id, config)
C++:
api.connect(
"game-room",
"secret",
"Player-1",
"", // sessionId
"", // channelId
false, // enableWebrtcRelay
"private", // apiKeyScope
"CACHE" // pollSource
);
api.receive(sessionId, config); // Uses CACHE
๐ฎ Real-World Example: Gaming vs Audit
๐ฎ
Gaming Scenario - Ultra-Low Latency
Use pollSource: 'CACHE' - Air Hockey game needs to update paddle positions 60 times per second.
Cache-only polling provides sub-millisecond response times, perfect for real-time gameplay.
๐
Audit Scenario - Permanent History
Use pollSource: 'DATABASE' - Compliance system needs to retrieve all chat messages from last month.
Database provides complete, permanent message history for regulatory reporting and audit trails.
๐จ
Event Streaming - Recent Messages
Use pollSource: 'KAFKA' - Real-time event streaming for recent activity feeds.
Kafka provides high-throughput access to recent messages within the retention period.
๐
General Chat - Balanced Approach
Use pollSource: 'AUTO' - Normal chat application benefits from the automatic fallback.
Recent messages come from cache (fast), then Kafka, with database as the permanent backup.
๐ Future Enhancement
Channel-level capabilities will eventually control storage behavior per channel,
allowing fine-grained control over which layers are used for different types of channels
(e.g., ephemeral-only channels, audit channels, etc.).
โก Ephemeral Message Flow
Ephemeral messages provide low-latency, non-persistent communication ideal for real-time updates like player positions, cursor movements, or live status changes.
1
Agent Sends Ephemeral Message
Message is sent with ephemeral: true flag. The message is not stored in the database and is only held in memory.
2
Service Routes to Connected Agents
The messaging service immediately delivers the message to all connected agents in the channel without persistence overhead.
3
Message Discarded After Delivery
Once delivered, ephemeral messages are discarded. Agents that join later will not receive historical ephemeral messages.
๐ก
Use Cases for Ephemeral Messages
Player positions in games, cursor movements in collaborative tools, live typing indicators, real-time sensor data, and other high-frequency updates that don't need persistence.
๐ Protocol Support
The platform supports multiple communication protocols for different use cases.
The platform provides signaling support for WebRTC peer-to-peer connections.
๐ฅ WEBRTC SIGNALING FLOW
โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ
โ Browser A โ โ MESSAGING CHANNELโ โ Browser B โ
โ agentName: "alice" โ โ (Signaling) โ โ agentName: "bob" โ
โ (Caller) โ โ โ (Callee) โ
โโโโโโโโโโโโฌโโโโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโ โโโโโโโโโโโโฌโโโโโโโโโโโ
โ โ โ
โ Both connected to same channel: โ โ
โ channelName: "video-room" โ โ
โ channelPassword: "secret" โ โ
โ apiKey: "key-123" โ โ
โ โ โ
โ 1. Create Offer (SDP) โ โ
โ send({to: "bob", type: WEBRTC}) โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโบโ โ
โ โ 2. Relay Offer to "bob" โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโบโ
โ โ โ
โ โ 3. Create Answer (SDP) โ
โ โ send({to: "alice", type: WEBRTC})
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 4. Relay Answer to "alice" โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ 5. Exchange ICE Candidates โ โ
โ (via channel messages) โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโบโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโบโ
โ โ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 6. DIRECT P2P CONNECTION โ
โ (Video/Audio Stream) โ
โ No server involved! โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ The messaging channel is only used for signaling - actual media flows directly P2P!โ Use agentName to target specific peer for WebRTC offers/answers
๐ Quick Reference
๐ CONNECT API - ALL OPTIONS
// JavaScript Example - All Connection Options
const agent = new AgentConnection();
agent.connect({
// Required
channelName: 'my-channel', // Channel name
channelPassword: 'secret123', // Channel password (hashed automatically)
agentName: 'player-1', // Your agent identifier
// API Key Options
apiKey: 'your-api-key', // Original or Temporary API key
apiKeyScope: 'private', // 'private' (default) or 'public'
// Optional Features
autoReceive: true, // Auto-poll for messages
useWebsocket: true, // Use WebSocket if available
enableWebrtcRelay: false, // Enable WebRTC signaling relay
// Advanced
sessionId: null, // For reconnection
channelId: null, // Pre-computed channel ID
customEventType: 'game,chat' // Filter specific event types
});
// EVENT HANDLERS
agent.onMessage = (msg) => console.log('Received:', msg);
agent.onConnect = () => console.log('Connected!');
agent.onDisconnect = () => console.log('Disconnected');
agent.onError = (err) => console.error('Error:', err);
๐ฎ Mini-Games
Interactive multiplayer games built with the Messaging Platform SDK. These examples demonstrate real-time communication,
WebRTC peer-to-peer networking, physics synchronization, and game state management.
โญ FEATURED
๐
Air Hockey
Classic 2-player air hockey game with realistic physics. Use your paddle to hit the puck
into your opponent's goal. Perfect showcase of real-time P2P gameplay!
3D racing game with physics-based ball controls. Race against other players through
obstacles, boost pads, and checkpoints to reach the finish line first.
2-4 players real-time racing
Three.js 3D graphics
Physics synchronization
Multiple race tracks
Boost & stamina system
Coming Soon
IN PROGRESS
๐
Fall Guys Race
Obstacle course racing game inspired by Fall Guys. Navigate through challenging obstacles,
avoid hazards, and race to the finish line with other players.
Multi-player obstacle racing
Dynamic obstacles
Colorful 3D graphics
Player collisions
Multiple rounds
Coming Soon
๐ง Technical Implementation
All games are built using the Messaging Platform SDK with:
๐ก
Real-time Messaging
AgentConnection for player synchronization and game events
๐
WebRTC P2P
Low-latency peer-to-peer for fast-paced gameplay (10-30ms)
๐จ
Three.js Graphics
3D rendering, physics simulation, and visual effects
๐พ
Channel Storage
Persistent game state, leaderboards, and player progress
๐ป Code Examples
Quick code snippets to get you started with the Messaging Platform SDK. For complete documentation,
visit the User Guide.
Comprehensive real-time communication features for building modern multiplayer applications
Core Communication
๐ก
Real-time Messaging
WebSocket-based messaging with automatic reconnection, message ordering, and delivery guarantees.
Support for text, binary, and structured data.
๐
WebRTC P2P
Ultra-low latency peer-to-peer communication (10-30ms) using WebRTC DataChannels.
Perfect for real-time games and interactive applications.
๐
Channel Isolation
Private and public channel scopes with password protection. Flexible API key system
with temporary keys for client-side applications.
๐พ
Channel Storage
Persistent key-value storage per channel. Perfect for game state, leaderboards,
settings, and any data that needs to survive across sessions.
๐
Multi-Platform SDKs
Consistent API across JavaScript (Web), Java (Desktop), Python (Scripts), and C++ (Games).
Write once, deploy everywhere.
๐น
Video/Audio Streaming
WebRTC video and audio streaming with camera, screen sharing, and recording capabilities.
Built-in TURN/STUN server support.
Developer Experience
๐จโ๐ป
Developer Portal
Web-based dashboard for API key management, channel monitoring, usage statistics,
and account settings. No installation required.
๐
Comprehensive Docs
Detailed documentation with code examples, tutorials, and best practices.
Interactive demos and working examples for every feature.
๐
Quick Start
Get started in minutes with simple API design and minimal configuration.
Include SDK files, connect to a channel, and start messaging.
๐ง
Debugging Tools
Built-in connection testing, TURN/STUN verification, WebRTC diagnostics,
and comprehensive logging for troubleshooting.
๐ฎ
Game-Ready Examples
Complete multiplayer game examples including racing, air hockey, quiz battle,
and more. Learn from production-ready code.
๐ฑ
Mobile Optimized
Responsive design and touch-friendly interfaces. All demos and games work
seamlessly on mobile devices and tablets.
๐ฎ
Coming Soon
๐ Advanced Analytics
๐ Push Notifications
๐ค Bot SDK
๐ Regional Servers
๐ฆ File Sharing
๐ End-to-End Encryption
๐ Current Status
๐ง
Free Pre-Production Demo
This SDK is currently available as a free demo and pre-production release for exploration, testing, and feedback.
The platform is in active development, and APIs, features, and functionality may change as we refine the system.
What This Means:
โThe SDK is completely free to use for development and experimentation
โThere are no paid plans or pricing commitments at this time
โAPIs and features may change as we gather feedback and improve the platform
โThis is an excellent opportunity to explore real-time messaging capabilities and provide input
โ ๏ธ
Not Recommended for Production
As this is a pre-production release, we recommend using it for development, testing, and prototyping rather than production deployments.
Service availability and data persistence are not guaranteed during this phase.
We're actively working toward a stable production release. If you have questions, feedback, or encounter issues,
please reach outโyour input helps shape the platform's future.
Current Features & Capabilities
๐
Full SDK AccessWeb, Java, Python, and C++ SDKs with complete API access
๐ก
Real-Time MessagingChannel-based messaging with encryption and ephemeral support
๐น
WebRTC IntegrationSignaling support for peer-to-peer connections
Allow developers to run authoritative game servers with full control over game logic
Webhook Integration
HTTP POST to developer's server for all game events
WebSocket Connection
Persistent connection for real-time event streaming
Server-Side Agent
Developer's server acts as special relay agent
โจ
Recent Updates
Latest improvements and additions to the platform
January 31, 2026:NEWAPI Key Scope Feature
New apiKeyScope parameter for channel isolation. Use "private" (default) for production or "public" for testing/demos.
January 31, 2026:NEWArchitecture Diagrams
Added SVG architecture diagrams: System Overview, API Key System, Private/Public Scope visualization, Connection Flow, and Protocol Support status.
January 31, 2026:NEWTemporary API Key Docs
Clarified temporary API keys are optional. Use original API key directly or temporary keys for enhanced client-side security.
January 2026:Multi-Mode Relay Architecture
Added 5 communication modes, unified WebRtcHelper, and Node.js SFU server
January 2026:TURN/STUN Over TLS
Added TCP-TLS relay on port 443 for corporate/VPN environments
January 2026:Developer Console
API key request system with admin approval, email notifications, and developer portal
January 2026:Whiteboard Enhancements
Professional undo/redo system, board locking, zoom controls, and mobile optimization
๐พ
Channel Storage API
PARTIAL
Persistent key-value storage for channels. Store game state, leaderboards, and settings.
โWeb Agent (JS)
Complete implementation with PUT, GET, DELETE, and LIST operations
โณJava Agent
Coming soon - same API for desktop and server applications
โณPython Agent
Coming soon - async/await support for bots and scripts
โณC++ Agent
Coming soon - high-performance game integration
Try it now: Check out the Storage Demo to see the Channel Storage API in action with the Web Agent.
๐ก Have Suggestions?
This platform is evolving based on developer feedback. Request an API key to start building and share your ideas!
๐ Request API Key
Fill out the form below to request a free API key. Your request will be reviewed by an admin,
and you'll receive your credentials via email upon approval.