Skip to content

Commit

Permalink
Update signaling client (#18068)
Browse files Browse the repository at this point in the history
* update signaling client

* format code

* fix

* update api view

* keep the api same

* format the code

* add signaling client options

* update signaling client

* format code

* fix

* update api view

* keep the api same

* format the code

* add signaling client options

* fix package
  • Loading branch information
LuChen-Microsoft authored Oct 8, 2021
1 parent 3304363 commit 051d17f
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 14 deletions.
8 changes: 4 additions & 4 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion sdk/communication/communication-chat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Release History

## 1.1.0 ((2021-09-15)
## 1.1.1 (Not released)

### Features Added
- Updated to @azure/communication-signaling@1.0.0-beta.11.
- Added `signalingClientOptions` in `ClientOptions`.

## 1.1.0 (2021-09-15)

### Features Added

Expand Down
4 changes: 2 additions & 2 deletions sdk/communication/communication-chat/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure/communication-chat",
"version": "1.1.0",
"version": "1.1.1",
"description": "Azure client library for Azure Communication Chat services",
"sdk-type": "client",
"main": "dist/index.js",
Expand Down Expand Up @@ -65,7 +65,7 @@
"dependencies": {
"@azure/abort-controller": "^1.0.0",
"@azure/communication-common": "^1.1.0",
"@azure/communication-signaling": "1.0.0-beta.10",
"@azure/communication-signaling": "1.0.0-beta.11",
"@azure/core-auth": "^1.3.0",
"@azure/core-client": "^1.0.0",
"@azure/core-rest-pipeline": "^1.1.0",
Expand Down
10 changes: 7 additions & 3 deletions sdk/communication/communication-chat/src/chatClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ export class ChatClient {
const authPolicy = createCommunicationTokenCredentialPolicy(this.tokenCredential);
this.client.pipeline.addPolicy(authPolicy);

this.signalingClient = getSignalingClient(credential, logger);
this.signalingClient = getSignalingClient(
credential,
logger,
(options as any).signalingClientOptions
);
}

/**
Expand Down Expand Up @@ -238,7 +242,7 @@ export class ChatClient {
}

this.isRealtimeNotificationsStarted = true;
this.signalingClient.start();
await this.signalingClient.start();
this.subscribeToSignalingEvents();
}

Expand All @@ -252,7 +256,7 @@ export class ChatClient {
}

this.isRealtimeNotificationsStarted = false;
this.signalingClient.stop();
await this.signalingClient.stop();
this.emitter.removeAllListeners();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
import { CommunicationSignalingClient, SignalingClient } from "@azure/communication-signaling";
import { CommunicationTokenCredential } from "@azure/communication-common";
import { AzureLogger } from "@azure/logger";
import { SignalingClientOptions } from "./signalingClient";

export const getSignalingClient = (
credential: CommunicationTokenCredential,
logger: AzureLogger
logger: AzureLogger,
options?: SignalingClientOptions
): SignalingClient | undefined => {
return new CommunicationSignalingClient(credential, logger);
return new CommunicationSignalingClient(credential, logger, {
environment: options?.environment ?? undefined
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ import { CommunicationSignalingClient, SignalingClient } from "@azure/communicat
import { CommunicationTokenCredential } from "@azure/communication-common";
import { AzureLogger } from "@azure/logger";

export interface SignalingClientOptions {
environment?: string;
}

export const getSignalingClient = (
credential: CommunicationTokenCredential,
logger: AzureLogger
logger: AzureLogger,
options?: SignalingClientOptions
): SignalingClient | undefined => {
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
// In React Native
return new CommunicationSignalingClient(credential, logger);
return new CommunicationSignalingClient(credential, logger, {
environment: options?.environment ?? undefined
});
}

// In node js
Expand Down

0 comments on commit 051d17f

Please sign in to comment.