connect( key, channel )
Description
The connect method initializes the connection between your application and the data center. It is a required step for enabling the monitoring process, as it ensures that all the collected data is sent back to the data center. Think of this method as the foundational setup (similar to init) for the entire system.
⚠️ Notes
- The
keyparameter is mandatory. Without a validauthorizationKey, the connection will not be established. - The
channelparameter is optional. If not provided, the system will use a default configuration for data streams. - Ensure that you call this method before any other methods, as it sets up the foundational connection for monitoring.
Syntax
javascript
import JBLWebSocket from '@/assets/js/jbl.es.js';
const authorizationKey = ${Product authorization key};
JBLWebSocket.connect(authorizationKey);Parameters
| Parameter | Type | Description |
|---|---|---|
key | String | Required,The authorizationKey provided for authentication. This is a mandatory parameter. |
channel | String | Optional,The Channel Name for grouping or categorizing data streams. This is an optional parameter. |
Usage
Basic Example
Use the connect method to authenticate and start monitoring data for your application:
javascript
const authorizationKey = 'your-auth-key';
JBLWebSocket.connect(authorizationKey);Example with Channel
If you want to define a specific channel for data categorization:
javascript
const authorizationKey = 'your-auth-key';
const channelName = 'MyChannel';
JBLWebSocket.connect(authorizationKey, channelName);