@azure/web-pubsub 1.0.1-alpha.20220325.2 → 1.1.0-alpha.20220407.2
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +5 -1
- package/dist/index.js +71 -151
- package/dist/index.js.map +1 -1
- package/dist-esm/src/generated/generatedClientContext.js +1 -1
- package/dist-esm/src/generated/generatedClientContext.js.map +1 -1
- package/dist-esm/src/groupClient.js +21 -45
- package/dist-esm/src/groupClient.js.map +1 -1
- package/dist-esm/src/hubClient.js +49 -105
- package/dist-esm/src/hubClient.js.map +1 -1
- package/dist-esm/src/tracing.js +3 -3
- package/dist-esm/src/tracing.js.map +1 -1
- package/dist-esm/test/hubs.spec.js +38 -1
- package/dist-esm/test/hubs.spec.js.map +1 -1
- package/package.json +3 -2
@@ -24,7 +24,7 @@ export class GeneratedClientContext extends coreClient.ServiceClient {
|
|
24
24
|
const defaults = {
|
25
25
|
requestContentType: "application/json; charset=utf-8"
|
26
26
|
};
|
27
|
-
const packageDetails = `azsdk-js-web-pubsub/1.0
|
27
|
+
const packageDetails = `azsdk-js-web-pubsub/1.1.0`;
|
28
28
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
29
29
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
30
30
|
: `${packageDetails}`;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generatedClientContext.js","sourceRoot":"","sources":["../../../src/generated/generatedClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,gBAAgB;AAChB,MAAM,OAAO,sBAAuB,SAAQ,UAAU,CAAC,aAAa;IAIlE;;;;OAIG;IACH,YAAY,QAAgB,EAAE,OAAuC;QACnE,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAC9C;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAAkC;YAC9C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,2BAA2B,CAAC;QACnD,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,YAAY,GAC1C,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,wBAAwB;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,0CAA0C;QAC1C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,YAAY,CAAC;IACvD,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { GeneratedClientOptionalParams } from \"./models\";\n\n/** @internal */\nexport class GeneratedClientContext extends coreClient.ServiceClient {\n endpoint: string;\n apiVersion: string;\n\n /**\n * Initializes a new instance of the GeneratedClientContext class.\n * @param endpoint HTTP or HTTPS endpoint for the Web PubSub service instance.\n * @param options The parameter options\n */\n constructor(endpoint: string, options?: GeneratedClientOptionalParams) {\n if (endpoint === undefined) {\n throw new Error(\"'endpoint' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: GeneratedClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-web-pubsub/1.0
|
1
|
+
{"version":3,"file":"generatedClientContext.js","sourceRoot":"","sources":["../../../src/generated/generatedClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,gBAAgB;AAChB,MAAM,OAAO,sBAAuB,SAAQ,UAAU,CAAC,aAAa;IAIlE;;;;OAIG;IACH,YAAY,QAAgB,EAAE,OAAuC;QACnE,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAC9C;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAAkC;YAC9C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,2BAA2B,CAAC;QACnD,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,YAAY,GAC1C,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,wBAAwB;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,0CAA0C;QAC1C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,YAAY,CAAC;IACvD,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { GeneratedClientOptionalParams } from \"./models\";\n\n/** @internal */\nexport class GeneratedClientContext extends coreClient.ServiceClient {\n endpoint: string;\n apiVersion: string;\n\n /**\n * Initializes a new instance of the GeneratedClientContext class.\n * @param endpoint HTTP or HTTPS endpoint for the Web PubSub service instance.\n * @param options The parameter options\n */\n constructor(endpoint: string, options?: GeneratedClientOptionalParams) {\n if (endpoint === undefined) {\n throw new Error(\"'endpoint' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: GeneratedClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-web-pubsub/1.1.0`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint || \"{Endpoint}\"\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.endpoint = endpoint;\n\n // Assigning values to Constant parameters\n this.apiVersion = options.apiVersion || \"2021-10-01\";\n }\n}\n"]}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
2
2
|
// Licensed under the MIT license.
|
3
3
|
import { RestError } from "@azure/core-rest-pipeline";
|
4
|
-
import {
|
4
|
+
import { tracingClient } from "./tracing";
|
5
5
|
import { getPayloadForMessage } from "./utils";
|
6
6
|
/**
|
7
7
|
* @hidden
|
@@ -26,15 +26,14 @@ export class WebPubSubGroupImpl {
|
|
26
26
|
* @param options - Additional options
|
27
27
|
*/
|
28
28
|
async addConnection(connectionId, options = {}) {
|
29
|
-
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-addConnection", options);
|
30
29
|
let response;
|
31
30
|
function onResponse(rawResponse, flatResponse) {
|
32
31
|
response = rawResponse;
|
33
|
-
if (
|
34
|
-
|
32
|
+
if (options.onResponse) {
|
33
|
+
options.onResponse(rawResponse, flatResponse);
|
35
34
|
}
|
36
35
|
}
|
37
|
-
|
36
|
+
return tracingClient.withSpan("WebPubSubGroupClient.addConnection", options, async (updatedOptions) => {
|
38
37
|
await this.client.webPubSub.addConnectionToGroup(this.hubName, this.groupName, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
39
38
|
if (response.status === 404) {
|
40
39
|
throw new RestError(`Connection id '${connectionId}' doesn't exist`, {
|
@@ -43,10 +42,7 @@ export class WebPubSubGroupImpl {
|
|
43
42
|
response: response,
|
44
43
|
});
|
45
44
|
}
|
46
|
-
}
|
47
|
-
finally {
|
48
|
-
span.end();
|
49
|
-
}
|
45
|
+
});
|
50
46
|
}
|
51
47
|
/**
|
52
48
|
* Remove a specific connection from this group
|
@@ -55,13 +51,9 @@ export class WebPubSubGroupImpl {
|
|
55
51
|
* @param options - Additional options
|
56
52
|
*/
|
57
53
|
async removeConnection(connectionId, options = {}) {
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
}
|
62
|
-
finally {
|
63
|
-
span.end();
|
64
|
-
}
|
54
|
+
return tracingClient.withSpan("WebPubSubGroupClient.removeConnection", options, (updatedOptions) => {
|
55
|
+
return this.client.webPubSub.removeConnectionFromGroup(this.hubName, this.groupName, connectionId, updatedOptions);
|
56
|
+
});
|
65
57
|
}
|
66
58
|
/**
|
67
59
|
* Close all connections to this group
|
@@ -69,13 +61,9 @@ export class WebPubSubGroupImpl {
|
|
69
61
|
* @param options - Additional options
|
70
62
|
*/
|
71
63
|
async closeAllConnections(options = {}) {
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
}
|
76
|
-
finally {
|
77
|
-
span.end();
|
78
|
-
}
|
64
|
+
return tracingClient.withSpan("WebPubSubGroupClient.closeAllConnections", options, (updatedOptions) => {
|
65
|
+
return this.client.webPubSub.closeGroupConnections(this.hubName, this.groupName, updatedOptions);
|
66
|
+
});
|
79
67
|
}
|
80
68
|
/**
|
81
69
|
* Add a user to this group
|
@@ -84,13 +72,9 @@ export class WebPubSubGroupImpl {
|
|
84
72
|
* @param options - Additional options
|
85
73
|
*/
|
86
74
|
async addUser(username, options = {}) {
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
}
|
91
|
-
finally {
|
92
|
-
span.end();
|
93
|
-
}
|
75
|
+
return tracingClient.withSpan("WebPubSubGroupClient.addUser", options, (updatedOptions) => {
|
76
|
+
return this.client.webPubSub.addUserToGroup(this.hubName, this.groupName, username, updatedOptions);
|
77
|
+
});
|
94
78
|
}
|
95
79
|
/**
|
96
80
|
* Remove a user from this group
|
@@ -99,23 +83,15 @@ export class WebPubSubGroupImpl {
|
|
99
83
|
* @param options - Additional options
|
100
84
|
*/
|
101
85
|
async removeUser(username, options = {}) {
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
}
|
106
|
-
finally {
|
107
|
-
span.end();
|
108
|
-
}
|
86
|
+
return tracingClient.withSpan("WebPubSubGroupClient.removeUser", options, (updatedOptions) => {
|
87
|
+
return this.client.webPubSub.removeUserFromGroup(this.hubName, this.groupName, username, updatedOptions);
|
88
|
+
});
|
109
89
|
}
|
110
90
|
async sendToAll(message, options = {}) {
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
}
|
116
|
-
finally {
|
117
|
-
span.end();
|
118
|
-
}
|
91
|
+
return tracingClient.withSpan("WebPubSubGroupClient.sendToAll", options, (updatedOptions) => {
|
92
|
+
const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
|
93
|
+
return this.client.webPubSub.sendToGroup(this.hubName, this.groupName, contentType, payload, updatedOptions);
|
94
|
+
});
|
119
95
|
}
|
120
96
|
}
|
121
97
|
//# sourceMappingURL=groupClient.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"groupClient.js","sourceRoot":"","sources":["../../src/groupClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,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I,KAAK,CAAC,UAAU,CAAC,QAAgB,EAAE,UAAkC,EAAE;QAC5E,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC,yCAAyC,EAAE,OAAO,CAAC,CAAC;QAEhG,IAAI;YACF,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,mBAAmB,CAC7C,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,SAAS,EACd,QAAQ,EACR,cAAc,CACf,CAAC;SACH;gBAAS;YACR,IAAI,CAAC,GAAG,EAAE,CAAC;SACZ;IACH,CAAC;IAwBM,KAAK,CAAC,SAAS,CACpB,OAAoC,EACpC,UAA6D,EAAE;QAE/D,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC,wCAAwC,EAAE,OAAO,CAAC,CAAC;QAE/F,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,oBAAoB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAE/E,IAAI;YACF,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CACrC,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,SAAS,EACd,WAAW,EACX,OAAc,EACd,cAAc,CACf,CAAC;SACH;gBAAS;YACR,IAAI,CAAC,GAAG,EAAE,CAAC;SACZ;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CommonClientOptions, FullOperationResponse, OperationOptions } from \"@azure/core-client\";\nimport { RestError, RequestBodyType } from \"@azure/core-rest-pipeline\";\nimport { GeneratedClient } from \"./generated/generatedClient\";\nimport { createSpan } from \"./tracing\";\nimport { getPayloadForMessage } from \"./utils\";\nimport { JSONTypes } from \"./hubClient\";\n\n/**\n * Options for constructing a GroupAdmin client.\n */\nexport interface GroupAdminClientOptions extends CommonClientOptions {}\n\n/**\n * Options for adding a connection to a group.\n */\nexport interface GroupAddConnectionOptions extends OperationOptions {}\n\n/**\n * Options for adding a user to a group.\n */\nexport interface GroupAddUserOptions extends OperationOptions {}\n\n/**\n * Options for checking if a user is in a group\n */\nexport interface GroupHasUserOptions extends OperationOptions {}\n\n/**\n * Options for removing a user from a group\n */\nexport interface GroupRemoveUserOptions extends OperationOptions {}\n\n/**\n * Options for removing a connection from a group\n */\nexport interface GroupRemoveConnectionOptions extends OperationOptions {}\n\n/**\n * Options for sending messages to a group.\n */\nexport interface GroupSendToAllOptions extends OperationOptions {\n /**\n * Connection ids to exclude from receiving this message.\n */\n excludedConnections?: string[];\n}\n\n/**\n * Options for sending text messages to a group..\n */\nexport interface GroupSendTextToAllOptions extends OperationOptions {\n /**\n * Connection ids to exclude from receiving this message.\n */\n excludedConnections?: string[];\n contentType: \"text/plain\";\n}\n\n/**\n * Options for closing all connections to a group.\n */\nexport interface GroupCloseAllConnectionsOptions extends OperationOptions {\n /**\n * Reason the connection is being closed.\n */\n reason?: string;\n}\n\nexport interface WebPubSubGroup {\n /**\n * The name of this group\n */\n readonly groupName: string;\n\n /**\n * The name of the hub this group belongs to\n */\n readonly hubName: string;\n\n /**\n * The Web PubSub API version being used by this client\n */\n readonly apiVersion: string;\n\n /**\n * The Web PubSub endpoint this client is connected to\n */\n readonly endpoint: string;\n\n /**\n * Add a specific connection to this group\n *\n * @param connectionId - The connection id to add to this group\n * @param options - Additional options\n */\n addConnection(connectionId: string, options?: GroupAddConnectionOptions): Promise<void>;\n\n /**\n * Remove a specific connection from this group\n *\n * @param connectionId - The connection id to remove from this group\n * @param options - Additional options\n */\n removeConnection(connectionId: string, options?: GroupRemoveConnectionOptions): Promise<void>;\n\n /**\n * Close all connections to the group\n *\n * @param options - Additional options\n */\n closeAllConnections(options?: GroupCloseAllConnectionsOptions): Promise<void>;\n\n /**\n * Add a user to this group\n *\n * @param username - The user name to add\n * @param options - Additional options\n */\n addUser(username: string, options?: GroupAddUserOptions): Promise<void>;\n\n /**\n * Remove a user from this group\n *\n * @param username - The user name to remove\n * @param options - Additional options\n */\n removeUser(username: string, options?: GroupRemoveUserOptions): Promise<void>;\n\n /**\n * Send a text message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n sendToAll(message: string, options: GroupSendTextToAllOptions): Promise<void>;\n /**\n * Send a json message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise<void>;\n /**\n * Send a binary message to every connection in this group\n *\n * @param message - The binary message to send\n * @param options - Additional options\n */\n sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise<void>;\n}\n\n/**\n * @hidden\n */\nexport class WebPubSubGroupImpl implements WebPubSubGroup {\n private client!: GeneratedClient;\n\n /**\n * The name of this group\n */\n public readonly groupName: string;\n\n /**\n * The name of the hub this group belongs to\n */\n public readonly hubName: string;\n\n /**\n * The Web PubSub API version being used by this client\n */\n public readonly apiVersion: string = \"2020-10-01\";\n\n /**\n * The Web PubSub endpoint this client is connected to\n */\n public endpoint!: string;\n\n /**\n * @internal\n */\n constructor(client: GeneratedClient, hubName: string, groupName: string) {\n this.client = client;\n this.groupName = groupName;\n this.hubName = hubName;\n }\n /**\n * Add a specific connection to this group\n *\n * @param connectionId - The connection id to add to this group\n * @param options - Additional options\n */\n public async addConnection(\n connectionId: string,\n options: GroupAddConnectionOptions = {}\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\n \"WebPubSubServiceClient-group-addConnection\",\n options\n );\n\n let response: FullOperationResponse | undefined;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n response = rawResponse;\n if (updatedOptions.onResponse) {\n updatedOptions.onResponse(rawResponse, flatResponse);\n }\n }\n\n try {\n await this.client.webPubSub.addConnectionToGroup(this.hubName, this.groupName, connectionId, {\n ...updatedOptions,\n onResponse,\n });\n\n if (response!.status === 404) {\n throw new RestError(`Connection id '${connectionId}' doesn't exist`, {\n statusCode: response?.status,\n request: response?.request,\n response: response,\n });\n }\n } finally {\n span.end();\n }\n }\n\n /**\n * Remove a specific connection from this group\n *\n * @param connectionId - The connection id to remove from this group\n * @param options - Additional options\n */\n public async removeConnection(\n connectionId: string,\n options: GroupRemoveConnectionOptions = {}\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\n \"WebPubSubServiceClient-group-removeConnection\",\n options\n );\n\n try {\n await this.client.webPubSub.removeConnectionFromGroup(\n this.hubName,\n this.groupName,\n connectionId,\n updatedOptions\n );\n } finally {\n span.end();\n }\n }\n\n /**\n * Close all connections to this group\n *\n * @param options - Additional options\n */\n public async closeAllConnections(options: GroupCloseAllConnectionsOptions = {}): Promise<void> {\n const { span, updatedOptions } = createSpan(\n \"WebPubSubServiceClient-group-closeAllConnections\",\n options\n );\n\n try {\n return await this.client.webPubSub.closeGroupConnections(\n this.hubName,\n this.groupName,\n updatedOptions\n );\n } finally {\n span.end();\n }\n }\n /**\n * Add a user to this group\n *\n * @param username - The user name to add\n * @param options - Additional options\n */\n public async addUser(username: string, options: GroupAddUserOptions = {}): Promise<void> {\n const { span, updatedOptions } = createSpan(\"WebPubSubServiceClient-group-addUser\", options);\n\n try {\n await this.client.webPubSub.addUserToGroup(\n this.hubName,\n this.groupName,\n username,\n updatedOptions\n );\n } finally {\n span.end();\n }\n }\n\n /**\n * Remove a user from this group\n *\n * @param username - The user name to remove\n * @param options - Additional options\n */\n public async removeUser(username: string, options: GroupRemoveUserOptions = {}): Promise<void> {\n const { span, updatedOptions } = createSpan(\"WebPubSubServiceClient-group-removeUser\", options);\n\n try {\n await this.client.webPubSub.removeUserFromGroup(\n this.hubName,\n this.groupName,\n username,\n updatedOptions\n );\n } finally {\n span.end();\n }\n }\n\n /**\n * Send a text message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n public async sendToAll(message: string, options: GroupSendTextToAllOptions): Promise<void>;\n /**\n * Send a json message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n public async sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise<void>;\n /**\n * Send a binary message to every connection in this group\n *\n * @param message - The binary message to send\n * @param options - Additional options\n */\n public async sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise<void>;\n\n public async sendToAll(\n message: JSONTypes | RequestBodyType,\n options: GroupSendToAllOptions | GroupSendTextToAllOptions = {}\n ): Promise<void> {\n const { span, updatedOptions } = createSpan(\"WebPubSubServiceClient-group-sendToAll\", options);\n\n const { contentType, payload } = getPayloadForMessage(message, updatedOptions);\n\n try {\n await this.client.webPubSub.sendToGroup(\n this.hubName,\n this.groupName,\n contentType,\n payload as any,\n updatedOptions\n );\n } finally {\n span.end();\n }\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"groupClient.js","sourceRoot":"","sources":["../../src/groupClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,SAAS,EAAmB,MAAM,2BAA2B,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAmJ/C;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAuB7B;;OAEG;IACH,YAAY,MAAuB,EAAE,OAAe,EAAE,SAAiB;QAbvE;;WAEG;QACa,eAAU,GAAW,YAAY,CAAC;QAWhD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IACD;;;;;OAKG;IACI,KAAK,CAAC,aAAa,CACxB,YAAoB,EACpB,UAAqC,EAAE;QAEvC,IAAI,QAA2C,CAAC;QAChD,SAAS,UAAU,CAAC,WAAkC,EAAE,YAAqB;YAC3E,QAAQ,GAAG,WAAW,CAAC;YACvB,IAAI,OAAO,CAAC,UAAU,EAAE;gBACtB,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;aAC/C;QACH,CAAC;QAED,OAAO,aAAa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AK,CAAC,OAAO,CAAC,QAAgB,EAAE,UAA+B,EAAE;QACtE,OAAO,aAAa,CAAC,QAAQ,CAAC,8BAA8B,EAAE,OAAO,EAAE,CAAC,cAAc,EAAE,EAAE;YACxF,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CACzC,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,SAAS,EACd,QAAQ,EACR,cAAc,CACf,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,UAAU,CAAC,QAAgB,EAAE,UAAkC,EAAE;QAC5E,OAAO,aAAa,CAAC,QAAQ,CAAC,iCAAiC,EAAE,OAAO,EAAE,CAAC,cAAc,EAAE,EAAE;YAC3F,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,mBAAmB,CAC9C,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,SAAS,EACd,QAAQ,EACR,cAAc,CACf,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAwBM,KAAK,CAAC,SAAS,CACpB,OAAoC,EACpC,UAA6D,EAAE;QAE/D,OAAO,aAAa,CAAC,QAAQ,CAAC,gCAAgC,EAAE,OAAO,EAAE,CAAC,cAAc,EAAE,EAAE;YAC1F,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,oBAAoB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;YAC/E,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CACtC,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,SAAS,EACd,WAAW,EACX,OAAc,EACd,cAAc,CACf,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CommonClientOptions, FullOperationResponse, OperationOptions } from \"@azure/core-client\";\nimport { RestError, RequestBodyType } from \"@azure/core-rest-pipeline\";\nimport { GeneratedClient } from \"./generated/generatedClient\";\nimport { tracingClient } from \"./tracing\";\nimport { getPayloadForMessage } from \"./utils\";\nimport { JSONTypes } from \"./hubClient\";\n\n/**\n * Options for constructing a GroupAdmin client.\n */\nexport interface GroupAdminClientOptions extends CommonClientOptions {}\n\n/**\n * Options for adding a connection to a group.\n */\nexport interface GroupAddConnectionOptions extends OperationOptions {}\n\n/**\n * Options for adding a user to a group.\n */\nexport interface GroupAddUserOptions extends OperationOptions {}\n\n/**\n * Options for checking if a user is in a group\n */\nexport interface GroupHasUserOptions extends OperationOptions {}\n\n/**\n * Options for removing a user from a group\n */\nexport interface GroupRemoveUserOptions extends OperationOptions {}\n\n/**\n * Options for removing a connection from a group\n */\nexport interface GroupRemoveConnectionOptions extends OperationOptions {}\n\n/**\n * Options for sending messages to a group.\n */\nexport interface GroupSendToAllOptions extends OperationOptions {\n /**\n * Connection ids to exclude from receiving this message.\n */\n excludedConnections?: string[];\n}\n\n/**\n * Options for sending text messages to a group..\n */\nexport interface GroupSendTextToAllOptions extends OperationOptions {\n /**\n * Connection ids to exclude from receiving this message.\n */\n excludedConnections?: string[];\n contentType: \"text/plain\";\n}\n\n/**\n * Options for closing all connections to a group.\n */\nexport interface GroupCloseAllConnectionsOptions extends OperationOptions {\n /**\n * Reason the connection is being closed.\n */\n reason?: string;\n}\n\nexport interface WebPubSubGroup {\n /**\n * The name of this group\n */\n readonly groupName: string;\n\n /**\n * The name of the hub this group belongs to\n */\n readonly hubName: string;\n\n /**\n * The Web PubSub API version being used by this client\n */\n readonly apiVersion: string;\n\n /**\n * The Web PubSub endpoint this client is connected to\n */\n readonly endpoint: string;\n\n /**\n * Add a specific connection to this group\n *\n * @param connectionId - The connection id to add to this group\n * @param options - Additional options\n */\n addConnection(connectionId: string, options?: GroupAddConnectionOptions): Promise<void>;\n\n /**\n * Remove a specific connection from this group\n *\n * @param connectionId - The connection id to remove from this group\n * @param options - Additional options\n */\n removeConnection(connectionId: string, options?: GroupRemoveConnectionOptions): Promise<void>;\n\n /**\n * Close all connections to the group\n *\n * @param options - Additional options\n */\n closeAllConnections(options?: GroupCloseAllConnectionsOptions): Promise<void>;\n\n /**\n * Add a user to this group\n *\n * @param username - The user name to add\n * @param options - Additional options\n */\n addUser(username: string, options?: GroupAddUserOptions): Promise<void>;\n\n /**\n * Remove a user from this group\n *\n * @param username - The user name to remove\n * @param options - Additional options\n */\n removeUser(username: string, options?: GroupRemoveUserOptions): Promise<void>;\n\n /**\n * Send a text message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n sendToAll(message: string, options: GroupSendTextToAllOptions): Promise<void>;\n /**\n * Send a json message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise<void>;\n /**\n * Send a binary message to every connection in this group\n *\n * @param message - The binary message to send\n * @param options - Additional options\n */\n sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise<void>;\n}\n\n/**\n * @hidden\n */\nexport class WebPubSubGroupImpl implements WebPubSubGroup {\n private client!: GeneratedClient;\n\n /**\n * The name of this group\n */\n public readonly groupName: string;\n\n /**\n * The name of the hub this group belongs to\n */\n public readonly hubName: string;\n\n /**\n * The Web PubSub API version being used by this client\n */\n public readonly apiVersion: string = \"2020-10-01\";\n\n /**\n * The Web PubSub endpoint this client is connected to\n */\n public endpoint!: string;\n\n /**\n * @internal\n */\n constructor(client: GeneratedClient, hubName: string, groupName: string) {\n this.client = client;\n this.groupName = groupName;\n this.hubName = hubName;\n }\n /**\n * Add a specific connection to this group\n *\n * @param connectionId - The connection id to add to this group\n * @param options - Additional options\n */\n public async addConnection(\n connectionId: string,\n options: GroupAddConnectionOptions = {}\n ): Promise<void> {\n let response: FullOperationResponse | undefined;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n response = rawResponse;\n if (options.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n }\n\n return tracingClient.withSpan(\n \"WebPubSubGroupClient.addConnection\",\n options,\n async (updatedOptions) => {\n await this.client.webPubSub.addConnectionToGroup(\n this.hubName,\n this.groupName,\n connectionId,\n {\n ...updatedOptions,\n onResponse,\n }\n );\n\n if (response!.status === 404) {\n throw new RestError(`Connection id '${connectionId}' doesn't exist`, {\n statusCode: response?.status,\n request: response?.request,\n response: response,\n });\n }\n }\n );\n }\n\n /**\n * Remove a specific connection from this group\n *\n * @param connectionId - The connection id to remove from this group\n * @param options - Additional options\n */\n public async removeConnection(\n connectionId: string,\n options: GroupRemoveConnectionOptions = {}\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubGroupClient.removeConnection\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.removeConnectionFromGroup(\n this.hubName,\n this.groupName,\n connectionId,\n updatedOptions\n );\n }\n );\n }\n\n /**\n * Close all connections to this group\n *\n * @param options - Additional options\n */\n public async closeAllConnections(options: GroupCloseAllConnectionsOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubGroupClient.closeAllConnections\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.closeGroupConnections(\n this.hubName,\n this.groupName,\n updatedOptions\n );\n }\n );\n }\n /**\n * Add a user to this group\n *\n * @param username - The user name to add\n * @param options - Additional options\n */\n public async addUser(username: string, options: GroupAddUserOptions = {}): Promise<void> {\n return tracingClient.withSpan(\"WebPubSubGroupClient.addUser\", options, (updatedOptions) => {\n return this.client.webPubSub.addUserToGroup(\n this.hubName,\n this.groupName,\n username,\n updatedOptions\n );\n });\n }\n\n /**\n * Remove a user from this group\n *\n * @param username - The user name to remove\n * @param options - Additional options\n */\n public async removeUser(username: string, options: GroupRemoveUserOptions = {}): Promise<void> {\n return tracingClient.withSpan(\"WebPubSubGroupClient.removeUser\", options, (updatedOptions) => {\n return this.client.webPubSub.removeUserFromGroup(\n this.hubName,\n this.groupName,\n username,\n updatedOptions\n );\n });\n }\n\n /**\n * Send a text message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n public async sendToAll(message: string, options: GroupSendTextToAllOptions): Promise<void>;\n /**\n * Send a json message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n public async sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise<void>;\n /**\n * Send a binary message to every connection in this group\n *\n * @param message - The binary message to send\n * @param options - Additional options\n */\n public async sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise<void>;\n\n public async sendToAll(\n message: JSONTypes | RequestBodyType,\n options: GroupSendToAllOptions | GroupSendTextToAllOptions = {}\n ): Promise<void> {\n return tracingClient.withSpan(\"WebPubSubGroupClient.sendToAll\", options, (updatedOptions) => {\n const { contentType, payload } = getPayloadForMessage(message, updatedOptions);\n return this.client.webPubSub.sendToGroup(\n this.hubName,\n this.groupName,\n contentType,\n payload as any,\n updatedOptions\n );\n });\n }\n}\n"]}
|
@@ -5,7 +5,7 @@ import { GeneratedClient } from "./generated/generatedClient";
|
|
5
5
|
import { WebPubSubGroupImpl } from "./groupClient";
|
6
6
|
import { isTokenCredential } from "@azure/core-auth";
|
7
7
|
import { webPubSubKeyCredentialPolicy } from "./webPubSubCredentialPolicy";
|
8
|
-
import {
|
8
|
+
import { tracingClient } from "./tracing";
|
9
9
|
import { logger } from "./logger";
|
10
10
|
import { parseConnectionString } from "./parseConnectionString";
|
11
11
|
import jwt from "jsonwebtoken";
|
@@ -62,34 +62,22 @@ export class WebPubSubServiceClient {
|
|
62
62
|
return new WebPubSubGroupImpl(this.client, this.hubName, groupName);
|
63
63
|
}
|
64
64
|
async sendToAll(message, options = {}) {
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
}
|
70
|
-
finally {
|
71
|
-
span.end();
|
72
|
-
}
|
65
|
+
return tracingClient.withSpan("WebPubSubServiceClient.sendToAll", options, (updatedOptions) => {
|
66
|
+
const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
|
67
|
+
return this.client.webPubSub.sendToAll(this.hubName, contentType, payload, updatedOptions);
|
68
|
+
});
|
73
69
|
}
|
74
70
|
async sendToUser(username, message, options = {}) {
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
}
|
80
|
-
finally {
|
81
|
-
span.end();
|
82
|
-
}
|
71
|
+
return tracingClient.withSpan("WebPubSubServiceClient.sendToUser", options, (updatedOptions) => {
|
72
|
+
const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
|
73
|
+
return this.client.webPubSub.sendToUser(this.hubName, username, contentType, payload, updatedOptions);
|
74
|
+
});
|
83
75
|
}
|
84
76
|
async sendToConnection(connectionId, message, options = {}) {
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
}
|
90
|
-
finally {
|
91
|
-
span.end();
|
92
|
-
}
|
77
|
+
return tracingClient.withSpan("WebPubSubServiceClient.sendToConnection", options, (updatedOptions) => {
|
78
|
+
const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
|
79
|
+
return this.client.webPubSub.sendToConnection(this.hubName, connectionId, contentType, payload, updatedOptions);
|
80
|
+
});
|
93
81
|
}
|
94
82
|
/**
|
95
83
|
* Check if a specific connection is connected to this hub
|
@@ -98,15 +86,14 @@ export class WebPubSubServiceClient {
|
|
98
86
|
* @param options - Additional options
|
99
87
|
*/
|
100
88
|
async connectionExists(connectionId, options = {}) {
|
101
|
-
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasConnection", options);
|
102
89
|
let response;
|
103
90
|
function onResponse(rawResponse, flatResponse) {
|
104
91
|
response = rawResponse;
|
105
|
-
if (
|
106
|
-
|
92
|
+
if (options.onResponse) {
|
93
|
+
options.onResponse(rawResponse, flatResponse);
|
107
94
|
}
|
108
95
|
}
|
109
|
-
|
96
|
+
return tracingClient.withSpan("WebPubSubServiceClient.connectionExists", options, async (updatedOptions) => {
|
110
97
|
await this.client.webPubSub.connectionExists(this.hubName, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
111
98
|
if (response.status === 200) {
|
112
99
|
return true;
|
@@ -122,10 +109,7 @@ export class WebPubSubServiceClient {
|
|
122
109
|
response: response,
|
123
110
|
});
|
124
111
|
}
|
125
|
-
}
|
126
|
-
finally {
|
127
|
-
span.end();
|
128
|
-
}
|
112
|
+
});
|
129
113
|
}
|
130
114
|
/**
|
131
115
|
* Close a specific connection to this hub
|
@@ -134,13 +118,9 @@ export class WebPubSubServiceClient {
|
|
134
118
|
* @param options - Additional options
|
135
119
|
*/
|
136
120
|
async closeConnection(connectionId, options = {}) {
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
}
|
141
|
-
finally {
|
142
|
-
span.end();
|
143
|
-
}
|
121
|
+
return tracingClient.withSpan("WebPubSubServiceClient.closeConnection", options, (updatedOptions) => {
|
122
|
+
return this.client.webPubSub.closeConnection(this.hubName, connectionId, updatedOptions);
|
123
|
+
});
|
144
124
|
}
|
145
125
|
/**
|
146
126
|
* Close all connections to this hub
|
@@ -148,13 +128,9 @@ export class WebPubSubServiceClient {
|
|
148
128
|
* @param options - Additional options
|
149
129
|
*/
|
150
130
|
async closeAllConnections(options = {}) {
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
}
|
155
|
-
finally {
|
156
|
-
span.end();
|
157
|
-
}
|
131
|
+
return tracingClient.withSpan("WebPubSubServiceClient.closeAllConnections", options, (updatedOptions) => {
|
132
|
+
return this.client.webPubSub.closeAllConnections(this.hubName, updatedOptions);
|
133
|
+
});
|
158
134
|
}
|
159
135
|
/**
|
160
136
|
* Close all connections with the given user id
|
@@ -163,13 +139,9 @@ export class WebPubSubServiceClient {
|
|
163
139
|
* @param options - Additional options
|
164
140
|
*/
|
165
141
|
async closeUserConnections(userId, options = {}) {
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
}
|
170
|
-
finally {
|
171
|
-
span.end();
|
172
|
-
}
|
142
|
+
return tracingClient.withSpan("WebPubSubServiceClient.closeUserConnections", options, (updatedOptions) => {
|
143
|
+
return this.client.webPubSub.closeUserConnections(this.hubName, userId, updatedOptions);
|
144
|
+
});
|
173
145
|
}
|
174
146
|
/**
|
175
147
|
* Remove a specific user from all groups they are joined to
|
@@ -177,13 +149,9 @@ export class WebPubSubServiceClient {
|
|
177
149
|
* @param options - Additional options
|
178
150
|
*/
|
179
151
|
async removeUserFromAllGroups(userId, options = {}) {
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
}
|
184
|
-
finally {
|
185
|
-
span.end();
|
186
|
-
}
|
152
|
+
return tracingClient.withSpan("WebPubSubServiceClient.removeUserFromAllGroups", options, (updatedOptions) => {
|
153
|
+
return this.client.webPubSub.removeUserFromAllGroups(this.hubName, userId, updatedOptions);
|
154
|
+
});
|
187
155
|
}
|
188
156
|
/**
|
189
157
|
* Check if a particular group exists (i.e. has active connections).
|
@@ -192,15 +160,14 @@ export class WebPubSubServiceClient {
|
|
192
160
|
* @param options - Additional options
|
193
161
|
*/
|
194
162
|
async groupExists(groupName, options = {}) {
|
195
|
-
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasGroup", options);
|
196
163
|
let response;
|
197
164
|
function onResponse(rawResponse, flatResponse) {
|
198
165
|
response = rawResponse;
|
199
|
-
if (
|
200
|
-
|
166
|
+
if (options.onResponse) {
|
167
|
+
options.onResponse(rawResponse, flatResponse);
|
201
168
|
}
|
202
169
|
}
|
203
|
-
|
170
|
+
return tracingClient.withSpan("WebPubSubServiceClient.groupExists", options, async (updatedOptions) => {
|
204
171
|
await this.client.webPubSub.groupExists(this.hubName, groupName, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
205
172
|
if (response.status === 200) {
|
206
173
|
return true;
|
@@ -215,10 +182,7 @@ export class WebPubSubServiceClient {
|
|
215
182
|
response: response,
|
216
183
|
});
|
217
184
|
}
|
218
|
-
}
|
219
|
-
finally {
|
220
|
-
span.end();
|
221
|
-
}
|
185
|
+
});
|
222
186
|
}
|
223
187
|
/**
|
224
188
|
* Check if a particular user is connected to this hub.
|
@@ -227,15 +191,14 @@ export class WebPubSubServiceClient {
|
|
227
191
|
* @param options - Additional options
|
228
192
|
*/
|
229
193
|
async userExists(username, options = {}) {
|
230
|
-
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasUser", options);
|
231
194
|
let response;
|
232
195
|
function onResponse(rawResponse, flatResponse) {
|
233
196
|
response = rawResponse;
|
234
|
-
if (
|
235
|
-
|
197
|
+
if (options.onResponse) {
|
198
|
+
options.onResponse(rawResponse, flatResponse);
|
236
199
|
}
|
237
200
|
}
|
238
|
-
|
201
|
+
return tracingClient.withSpan("WebPubSubServiceClient.userExists", options, async (updatedOptions) => {
|
239
202
|
await this.client.webPubSub.userExists(this.hubName, username, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
240
203
|
if (response.status === 200) {
|
241
204
|
return true;
|
@@ -251,10 +214,7 @@ export class WebPubSubServiceClient {
|
|
251
214
|
response: response,
|
252
215
|
});
|
253
216
|
}
|
254
|
-
}
|
255
|
-
finally {
|
256
|
-
span.end();
|
257
|
-
}
|
217
|
+
});
|
258
218
|
}
|
259
219
|
/**
|
260
220
|
* Grant permissions to a connection
|
@@ -264,13 +224,9 @@ export class WebPubSubServiceClient {
|
|
264
224
|
* @param options - Additional options
|
265
225
|
*/
|
266
226
|
async grantPermission(connectionId, permission, options = {}) {
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
}
|
271
|
-
finally {
|
272
|
-
span.end();
|
273
|
-
}
|
227
|
+
return tracingClient.withSpan("WebPubSubServiceClient.grantPermission", options, (updatedOptions) => {
|
228
|
+
return this.client.webPubSub.grantPermission(this.hubName, permission, connectionId, updatedOptions);
|
229
|
+
});
|
274
230
|
}
|
275
231
|
/**
|
276
232
|
* Revoke permissions from a connection
|
@@ -280,13 +236,9 @@ export class WebPubSubServiceClient {
|
|
280
236
|
* @param options - Additional options
|
281
237
|
*/
|
282
238
|
async revokePermission(connectionId, permission, options = {}) {
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
}
|
287
|
-
finally {
|
288
|
-
span.end();
|
289
|
-
}
|
239
|
+
return tracingClient.withSpan("WebPubSubServiceClient.revokePermission", options, (updatedOptions) => {
|
240
|
+
return this.client.webPubSub.revokePermission(this.hubName, permission, connectionId, updatedOptions);
|
241
|
+
});
|
290
242
|
}
|
291
243
|
/**
|
292
244
|
* Check if the connection has the specified permission
|
@@ -296,15 +248,14 @@ export class WebPubSubServiceClient {
|
|
296
248
|
* @param options - Additional options
|
297
249
|
*/
|
298
250
|
async hasPermission(connectionId, permission, options = {}) {
|
299
|
-
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasPermission", options);
|
300
251
|
let response;
|
301
252
|
function onResponse(rawResponse, flatResponse) {
|
302
253
|
response = rawResponse;
|
303
|
-
if (
|
304
|
-
|
254
|
+
if (options.onResponse) {
|
255
|
+
options.onResponse(rawResponse, flatResponse);
|
305
256
|
}
|
306
257
|
}
|
307
|
-
|
258
|
+
return tracingClient.withSpan("WebPubSubServiceClient.hasPermission", options, async (updatedOptions) => {
|
308
259
|
await this.client.webPubSub.checkPermission(this.hubName, permission, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
309
260
|
if (response.status === 200) {
|
310
261
|
return true;
|
@@ -320,10 +271,7 @@ export class WebPubSubServiceClient {
|
|
320
271
|
response: response,
|
321
272
|
});
|
322
273
|
}
|
323
|
-
}
|
324
|
-
finally {
|
325
|
-
span.end();
|
326
|
-
}
|
274
|
+
});
|
327
275
|
}
|
328
276
|
/**
|
329
277
|
* Generate a token for a client to connect to the Azure Web PubSub service.
|
@@ -331,8 +279,7 @@ export class WebPubSubServiceClient {
|
|
331
279
|
* @param options - Additional options
|
332
280
|
*/
|
333
281
|
async getClientAccessToken(options = {}) {
|
334
|
-
|
335
|
-
try {
|
282
|
+
return tracingClient.withSpan("WebPubSubServiceClient.getClientAccessToken", options, async (updatedOptions) => {
|
336
283
|
const endpoint = this.endpoint.endsWith("/") ? this.endpoint : this.endpoint + "/";
|
337
284
|
const clientEndpoint = endpoint.replace(/(http)(s?:\/\/)/gi, "ws$2");
|
338
285
|
const baseUrl = `${clientEndpoint}client/hubs/${this.hubName}`;
|
@@ -362,10 +309,7 @@ export class WebPubSubServiceClient {
|
|
362
309
|
baseUrl,
|
363
310
|
url: `${baseUrl}?access_token=${token}`,
|
364
311
|
};
|
365
|
-
}
|
366
|
-
finally {
|
367
|
-
span.end();
|
368
|
-
}
|
312
|
+
});
|
369
313
|
}
|
370
314
|
}
|
371
315
|
//# sourceMappingURL=hubClient.js.map
|