WebPubSubChatServiceClient class

A client for managing chat resources in an Azure Web PubSub Chat hub.

Properties

pipeline

The pipeline used by this client to make requests

Methods

createOrReplaceRole(string, ChatRoleInput, CreateOrReplaceRoleOptionalParams)

Create or replace a role.

createOrReplaceRoom(string, ChatRoomInput, CreateOrReplaceRoomOptionalParams)

Create or replace a room with a client-specified ID.

createOrReplaceRoomMember(string, string, ChatRoomMemberInput, CreateOrReplaceRoomMemberOptionalParams)

Create or replace a room member.

createOrReplaceUser(string, HumanChatUserInput, CreateOrReplaceUserOptionalParams)

Create or replace a user. The request body is a polymorphic ChatUser (e.g. HumanChatUser) selected by the kind discriminator.

deleteMessage(string, string, DeleteMessageOptionalParams)

Delete a message.

deleteRole(string, DeleteRoleOptionalParams)

Delete a role.

deleteRoom(string, DeleteRoomOptionalParams)

Delete a room.

deleteRoomMember(string, string, DeleteRoomMemberOptionalParams)

Delete a room member.

deleteUser(string, DeleteUserOptionalParams)

Delete a user.

getClientAccessToken(GetClientAccessTokenOptions)

Generate a token for a client to connect to the Azure Web PubSub service.

When using AzureKeyCredential, the token is generated locally using JWT signing. When using TokenCredential, the token is generated by calling the Web PubSub service's REST API.

getConversation(string, GetConversationOptionalParams)

Get conversation information.

getRole(string, GetRoleOptionalParams)

Get role information.

getRoom(string, GetRoomOptionalParams)

Get room information.

getUser(string, GetUserOptionalParams)

Get a user's profile. The response is a polymorphic ChatUser (e.g. HumanChatUser) selected by the kind discriminator.

listMessages(string, ListMessagesOptionalParams)

Query messages in a conversation from latest to earliest.

listRoles(ListRolesOptionalParams)

Query roles in a hub.

listRoomMembers(string, ListRoomMembersOptionalParams)

Get room members.

updateMessage(string, string, ChatMessageInput, UpdateMessageOptionalParams)

Update a message.

Constructor Details

WebPubSubChatServiceClient(string, string, WebPubSubChatServiceClientOptions)

Create from connection string

new WebPubSubChatServiceClient(connectionString: string, hub: string, options?: WebPubSubChatServiceClientOptions)

Parameters

connectionString

string

hub

string

WebPubSubChatServiceClient(string, TokenCredential | AzureKeyCredential, string, WebPubSubChatServiceClientOptions)

Create from endpoint and credential

new WebPubSubChatServiceClient(endpointParam: string, credential: TokenCredential | AzureKeyCredential, hub: string, options?: WebPubSubChatServiceClientOptions)

Parameters

endpointParam

string

hub

string

Property Details

pipeline

The pipeline used by this client to make requests

pipeline: Pipeline

Property Value

Method Details

createOrReplaceRole(string, ChatRoleInput, CreateOrReplaceRoleOptionalParams)

Create or replace a role.

function createOrReplaceRole(roleName: string, resource: ChatRoleInput, options?: CreateOrReplaceRoleOptionalParams): Promise<ChatRole>

Parameters

roleName

string

resource
ChatRoleInput

Returns

Promise<ChatRole>

createOrReplaceRoom(string, ChatRoomInput, CreateOrReplaceRoomOptionalParams)

Create or replace a room with a client-specified ID.

function createOrReplaceRoom(roomId: string, resource: ChatRoomInput, options?: CreateOrReplaceRoomOptionalParams): Promise<ChatRoom>

Parameters

roomId

string

resource
ChatRoomInput

Returns

Promise<ChatRoom>

createOrReplaceRoomMember(string, string, ChatRoomMemberInput, CreateOrReplaceRoomMemberOptionalParams)

Create or replace a room member.

function createOrReplaceRoomMember(roomId: string, userId: string, resource: ChatRoomMemberInput, options?: CreateOrReplaceRoomMemberOptionalParams): Promise<ChatRoomMember>

Parameters

roomId

string

userId

string

Returns

Promise<ChatRoomMember>

createOrReplaceUser(string, HumanChatUserInput, CreateOrReplaceUserOptionalParams)

Create or replace a user. The request body is a polymorphic ChatUser (e.g. HumanChatUser) selected by the kind discriminator.

function createOrReplaceUser(userId: string, resource: HumanChatUserInput, options?: CreateOrReplaceUserOptionalParams): Promise<ChatUserUnion>

Parameters

userId

string

Returns

Promise<ChatUserUnion>

deleteMessage(string, string, DeleteMessageOptionalParams)

Delete a message.

function deleteMessage(conversationId: string, messageId: string, options?: DeleteMessageOptionalParams): Promise<void>

Parameters

conversationId

string

messageId

string

Returns

Promise<void>

deleteRole(string, DeleteRoleOptionalParams)

Delete a role.

function deleteRole(roleName: string, options?: DeleteRoleOptionalParams): Promise<void>

Parameters

roleName

string

Returns

Promise<void>

deleteRoom(string, DeleteRoomOptionalParams)

Delete a room.

function deleteRoom(roomId: string, options?: DeleteRoomOptionalParams): Promise<void>

Parameters

roomId

string

Returns

Promise<void>

deleteRoomMember(string, string, DeleteRoomMemberOptionalParams)

Delete a room member.

function deleteRoomMember(roomId: string, userId: string, options?: DeleteRoomMemberOptionalParams): Promise<void>

Parameters

roomId

string

userId

string

Returns

Promise<void>

deleteUser(string, DeleteUserOptionalParams)

Delete a user.

function deleteUser(userId: string, options?: DeleteUserOptionalParams): Promise<void>

Parameters

userId

string

Returns

Promise<void>

getClientAccessToken(GetClientAccessTokenOptions)

Generate a token for a client to connect to the Azure Web PubSub service.

When using AzureKeyCredential, the token is generated locally using JWT signing. When using TokenCredential, the token is generated by calling the Web PubSub service's REST API.

function getClientAccessToken(options?: GetClientAccessTokenOptions): Promise<ClientAccessToken>

Parameters

Returns

getConversation(string, GetConversationOptionalParams)

Get conversation information.

function getConversation(conversationId: string, options?: GetConversationOptionalParams): Promise<ChatConversation>

Parameters

conversationId

string

Returns

Promise<ChatConversation>

getRole(string, GetRoleOptionalParams)

Get role information.

function getRole(roleName: string, options?: GetRoleOptionalParams): Promise<ChatRole>

Parameters

roleName

string

Returns

Promise<ChatRole>

getRoom(string, GetRoomOptionalParams)

Get room information.

function getRoom(roomId: string, options?: GetRoomOptionalParams): Promise<ChatRoom>

Parameters

roomId

string

Returns

Promise<ChatRoom>

getUser(string, GetUserOptionalParams)

Get a user's profile. The response is a polymorphic ChatUser (e.g. HumanChatUser) selected by the kind discriminator.

function getUser(userId: string, options?: GetUserOptionalParams): Promise<ChatUserUnion>

Parameters

userId

string

Returns

Promise<ChatUserUnion>

listMessages(string, ListMessagesOptionalParams)

Query messages in a conversation from latest to earliest.

function listMessages(conversationId: string, options?: ListMessagesOptionalParams): PagedAsyncIterableIterator<ChatMessage, ChatMessage[], PageSettings>

Parameters

conversationId

string

Returns

listRoles(ListRolesOptionalParams)

Query roles in a hub.

function listRoles(options?: ListRolesOptionalParams): PagedAsyncIterableIterator<ChatRole, ChatRole[], PageSettings>

Parameters

Returns

listRoomMembers(string, ListRoomMembersOptionalParams)

Get room members.

function listRoomMembers(roomId: string, options?: ListRoomMembersOptionalParams): PagedAsyncIterableIterator<ChatRoomMember, ChatRoomMember[], PageSettings>

Parameters

roomId

string

Returns

updateMessage(string, string, ChatMessageInput, UpdateMessageOptionalParams)

Update a message.

function updateMessage(conversationId: string, messageId: string, resource: ChatMessageInput, options?: UpdateMessageOptionalParams): Promise<ChatMessage>

Parameters

conversationId

string

messageId

string

resource
ChatMessageInput

Returns

Promise<ChatMessage>