WebSocket and real-time updates
The SDK streams Launchpad events over one socket.io connection, owned by StreamWebSocketService
(sdk.realtime on a LaunchpadSDK, or new StreamWebSocketService({ url }) on its own). Every
subscribe* call returns its own unsubscribe; a room is joined once, on its first subscriber, and left
on its last.
Where to start
- Quick start: subscribe to the global feed and one token's room in a few lines.
- Global feed: one subscription that carries a summary of every token and the site-wide switches.
- Authentication: authenticating the socket (user and overseer events, chat), token refresh and reconnects.
Event groups
Each event has a callback key (onX, in the callback objects subscribeToGlobalFeed and
connectStreamWebSocket take) and a typed method form (sdk.onX or service.subscribe*).
Global feed, token events (a summary of every token, no room to join):
onStreamStatus, onTradeExecuted, onHolderCountUpdated, onPoolBadgeAssigned, onViewerCount,
onTokenConfigUpdated, onStatsUpdated, onPoolCreated
Global feed, site configuration events (platform-wide switches):
onSiteConfigChanged, onStreamGlobalStatus, onChatGlobalStatus, onCommentsGlobalStatus,
onWebhooksGlobalStatus, onAIModerationGlobalStatus
A token's room (detail for one token; joined by subscribeToStream(tokenName) or
service.joinTokenRoom(tokenName)):
onChatMessage, onChatUpdated, onChatDeleted, onChatPinned, onChatUnpinned, onTypingIndicator,
onReaction, onContentReactionAdded, onContentReactionRemoved, onViewerCount, onStreamStatus,
onRecordingStatus, onSimulcastStatus, onEngagementStatsUpdated, onTradeExecuted, onBalanceUpdated
The complete, typed list is RealtimeEventPayloads (every event name and its payload) and
StreamEventCallbacks / GlobalFeedEventCallbacks (every callback key), both exported by the SDK.
Example
import { StreamWebSocketService } from '@gala-chain/launchpad-sdk';
const service = new StreamWebSocketService({ url: 'wss://stream.example.com' });
// Joins the global feed once the socket is up; returns this subscription's own unsubscribe.
const unsubscribe = service.subscribeToGlobalFeed({
onStreamGlobalStatus: (event) => {
console.log(`Streaming ${event.enabled ? 'enabled' : 'disabled'}`);
},
});
// Later: leave the feed (the room is left when the last subscriber is released).
unsubscribe();
service.disconnect();
FAQ
What is the difference between the global feed and a token room? The global feed broadcasts summary events for every token and the site configuration to every client. A token room carries the detailed events of one token (chat, reactions, moderation).
Can I filter events on the server? No. Subscribe to the global feed and filter in your callback.
Do I unsubscribe manually? Every subscribe* call returns its own unsubscribe; call it (in React,
return it from the effect). service.disconnect() releases everything.
Can several components subscribe? Yes, to the same event, token or room: each is its own subscriber, a room is joined once on the first subscriber and left on the last, and one subscriber that throws never stops the others.
How do I refresh an expired token? See Authentication: pass a
tokenProvider that answers with the token current at that moment.