Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update signaling client #18068

Merged
merged 17 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 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/[email protected].
- 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();
LuChen-Microsoft marked this conversation as resolved.
Show resolved Hide resolved
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