Connection Management
Note: In the SDK Playground, connection is automatic - you don't need these methods. They are only required when using a standalone client or when connecting to additional appliances from your code.
connect(robotId, token, options)
JavaScript:
JS
await oloClient.connect(robotId, token, options)Python:
Connect to an appliance via WebSocket using an authenticated token.
JavaScript Parameters:
robotId(string) - Appliance identifier fromgetUserRobots()token(string) - Authentication token fromauthenticate()orgetAuthToken()options(object, optional) - Connection optionsserverUrl(string) - Custom WebSocket server URLonConnect(function) - Callback when connectedonDisconnect(function) - Callback when disconnectedonError(function) - Callback for errors
Python Parameters:
robot_id(string) - Appliance identifier fromget_user_robots()token(string) - Authentication token fromauthenticate()orget_auth_token()server_host(string) - Server hostname (default: 'localhost')server_port(int) - Server port (default: 3000)use_ssl(bool) - Use WSS instead of WS (default: False)
Returns: Promise<boolean> - True if connection successful
Example:
JS
// After authentication
const appliances = await oloClient.getUserRobots();
const appliance = appliances[0];
// Connect to appliance
await oloClient.connect(appliance.id, oloClient.getAuthToken());
console.log('Connected to appliance!');disconnect()
Disconnect from appliance and clean up resources.
JS
oloClient.disconnect();
console.log('Disconnected from appliance');getConnectionStatus()
Get current connection status.
Returns: boolean - True if connected
JS
const isConnected = oloClient.getConnectionStatus();
console.log('Connection status:', isConnected);