UNPKG

@azure/web-pubsub

Version:
232 lines 7.66 kB
import type { CommonClientOptions, OperationOptions } from "@azure/core-client"; import type { RequestBodyType } from "@azure/core-rest-pipeline"; import type { GeneratedClient } from "./generated/generatedClient.js"; import type { JSONTypes } from "./hubClient.js"; /** * Options for constructing a GroupAdmin client. */ export interface GroupAdminClientOptions extends CommonClientOptions { } /** * Options for adding a connection to a group. */ export interface GroupAddConnectionOptions extends OperationOptions { } /** * Options for adding a user to a group. */ export interface GroupAddUserOptions extends OperationOptions { } /** * Options for checking if a user is in a group */ export interface GroupHasUserOptions extends OperationOptions { } /** * Options for removing a user from a group */ export interface GroupRemoveUserOptions extends OperationOptions { } /** * Options for removing a connection from a group */ export interface GroupRemoveConnectionOptions extends OperationOptions { } /** * Options for sending messages to a group. */ export interface GroupSendToAllOptions extends OperationOptions { /** * Connection ids to exclude from receiving this message. */ excludedConnections?: string[]; /** * The filter syntax to filter out the connections to send the messages to following OData filter syntax. * Examples: * * Exclude connections from `user1` and `user2`: `userId ne 'user1' and userId ne 'user2'` * * Exclude connections in `group1`: `not('group1' in groups)` * Details about `filter` syntax please see [OData filter syntax for Azure Web PubSub](https://aka.ms/awps/filter-syntax). */ filter?: string; /** * The time-to-live (TTL) value in seconds for messages sent to the service. * 0 is the default value, which means the message never expires. * 300 is the maximum value. * If this parameter is non-zero, messages that are not consumed by the client within the specified TTL will be dropped by the service. * This parameter can help when the client's bandwidth is limited. */ messageTtlSeconds?: number; } /** * Options for sending text messages to a group.. */ export interface GroupSendTextToAllOptions extends GroupSendToAllOptions { /** * The content will be sent to the clients in plain text. */ contentType: "text/plain"; } /** * Options for closing all connections to a group. */ export interface GroupCloseAllConnectionsOptions extends OperationOptions { /** * Reason the connection is being closed. */ reason?: string; } export interface WebPubSubGroup { /** * The name of this group */ readonly groupName: string; /** * The name of the hub this group belongs to */ readonly hubName: string; /** * The Web PubSub API version being used by this client */ readonly apiVersion: string; /** * The Web PubSub endpoint this client is connected to */ readonly endpoint: string; /** * Add a specific connection to this group * * @param connectionId - The connection id to add to this group * @param options - Additional options */ addConnection(connectionId: string, options?: GroupAddConnectionOptions): Promise<void>; /** * Remove a specific connection from this group * * @param connectionId - The connection id to remove from this group * @param options - Additional options */ removeConnection(connectionId: string, options?: GroupRemoveConnectionOptions): Promise<void>; /** * Close all connections to the group * * @param options - Additional options */ closeAllConnections(options?: GroupCloseAllConnectionsOptions): Promise<void>; /** * Add a user to this group * * @param username - The user name to add * @param options - Additional options */ addUser(username: string, options?: GroupAddUserOptions): Promise<void>; /** * Remove a user from this group * * @param username - The user name to remove * @param options - Additional options */ removeUser(username: string, options?: GroupRemoveUserOptions): Promise<void>; /** * Send a text message to every connection in this group * * @param message - The message to send * @param options - Additional options */ sendToAll(message: string, options: GroupSendTextToAllOptions): Promise<void>; /** * Send a json message to every connection in this group * * @param message - The message to send * @param options - Additional options */ sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise<void>; /** * Send a binary message to every connection in this group * * @param message - The binary message to send * @param options - Additional options */ sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise<void>; } /** * @hidden */ export declare class WebPubSubGroupImpl implements WebPubSubGroup { private client; /** * The name of this group */ readonly groupName: string; /** * The name of the hub this group belongs to */ readonly hubName: string; /** * The Web PubSub API version being used by this client */ readonly apiVersion: string; /** * The Web PubSub endpoint this client is connected to */ endpoint: string; /** * @internal */ constructor(client: GeneratedClient, hubName: string, groupName: string); /** * Add a specific connection to this group * * @param connectionId - The connection id to add to this group * @param options - Additional options */ addConnection(connectionId: string, options?: GroupAddConnectionOptions): Promise<void>; /** * Remove a specific connection from this group * * @param connectionId - The connection id to remove from this group * @param options - Additional options */ removeConnection(connectionId: string, options?: GroupRemoveConnectionOptions): Promise<void>; /** * Close all connections to this group * * @param options - Additional options */ closeAllConnections(options?: GroupCloseAllConnectionsOptions): Promise<void>; /** * Add a user to this group * * @param username - The user name to add * @param options - Additional options */ addUser(username: string, options?: GroupAddUserOptions): Promise<void>; /** * Remove a user from this group * * @param username - The user name to remove * @param options - Additional options */ removeUser(username: string, options?: GroupRemoveUserOptions): Promise<void>; /** * Send a text message to every connection in this group * * @param message - The message to send * @param options - Additional options */ sendToAll(message: string, options: GroupSendTextToAllOptions): Promise<void>; /** * Send a json message to every connection in this group * * @param message - The message to send * @param options - Additional options */ sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise<void>; /** * Send a binary message to every connection in this group * * @param message - The binary message to send * @param options - Additional options */ sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise<void>; } //# sourceMappingURL=groupClient.d.ts.map