FunnableChat
Real-time lobby chat powered by the platform's WebSocket infrastructure. Handles connection retries, ping/pong heartbeats, and exposes ergonomic hooks for reacting to new messages or membership changes.
FunnableChat
Real-time lobby chat powered by the platform's WebSocket infrastructure. Handles connection retries, ping/pong heartbeats, and exposes ergonomic hooks for reacting to new messages or membership changes.
Examples
const sdk = Funnable.init();
const stop = sdk.chat.onMessage((msg) => console.log(msg.content));
sdk.chat.connect(lobbyId, authToken);
sdk.chat.send("GLHF!");Members
connect
connect(lobbyId: string, token: string): voidOpens a chat socket for the provided lobby. Automatically starts a heartbeat every 30 seconds to avoid idle disconnects.
send
send(content: string): voidBroadcasts a text message into the connected lobby.
onMessage
onMessage(cb: MessageCallback): () => voidRegisters a callback that fires whenever another player sends a message. Returns an unsubscribe function for teardown.
Examples
const unsubscribe = sdk.chat.onMessage((msg) => {
ui.append(`${msg.name}: ${msg.content}`);
});onUserJoined
onUserJoined(cb: SystemCallback): () => voidRegisters a handler that fires when a player joins the lobby.
onUserLeft
onUserLeft(cb: SystemCallback): () => voidRegisters a handler that fires when a player leaves the lobby.
disconnect
disconnect(): voidStops the heartbeat and closes the socket. Safe to call even if no connection exists.