- Docs
- API Reference
- Socket SDK
- Socket SDK Connection
Socket SDK Connection
Access via socket.connection.
Methods
| Method | Returns | Description |
|---|---|---|
connect() | Promise | Open the WebSocket |
disconnect() | void | Close the connection |
ping() | Promise<number> | RTT in milliseconds |
isConnected() | boolean | Current state |
on(event, handler) | void | Subscribe to events |
Events
| Event | Payload highlights |
|---|---|
initialized | — |
connecting | attempt |
opened | Transport open |
connected | connectionId, connectionDetails |
disconnected | — |
closing | Intentional close |
closed | code, reason |
failed | error, context |
socket.connection.on("connected", ({ connectionId }) => {
console.log(connectionId);
});
Conceptual guide: Connection Lifecycle.
Previous
Socket SDK
Next
Channels