Azure Communication Signaling Client
npm install @azure/communication-signalingbash
npm install @azure/communication-signaling
`
$3
#### JavaScript Bundle
This client library is only supported in the browser. To use this client library, first you need to use a bundler. For details on how to do this, please refer to our bundling documentation.
Key concepts
$3
SignalingClient is the primary interface for developers using this client library. It provides methods to enable/disable real-time notifications and register listeners for different events.
Examples
$3
Use user access token and Azure logger to initialize signaling client.
`JavaScript
import { CommunicationSignalingClient } from '@azure/communication-signaling';
import { AzureCommunicationTokenCredential } from "@azure/communication-common";
import { createClientLogger } from "@azure/logger";
let userAccessToken = '';
let tokenCredential = new AzureCommunicationTokenCredential(userAccessToken);
let logger = createClientLogger("communication-signaling");
let signalingClient = new CommunicationSignalingClient(tokenCredential, logger);
`
$3
`JavaScript
signalingClient.start();
`
$3
`JavaScript
signalingClient.stop();
`
$3
With real-time signaling, you can subscribe to listen for new incoming events and call your own business logic accordingly.
`JavaScript
// register listener to new incoming message event
signalingClient.on("chatMessageReceived", (payload) => {
console.log("Notification chatMessageReceived!");
// your code here
});
// register listener to typing indicator event
signalingClient.on("typingIndicatorReceived", (payload) => {
console.log("Notification typingIndicatorReceived!");
// your code here
});
// register listener to thread deleted event
signalingClient.on("chatThreadDeleted", (payload) => {
console.log("Notification chatThreadDeleted!");
// your code here
});
``