Partilhar via


WebPubSubServiceClient Class

  • java.lang.Object
    • com.azure.messaging.webpubsub.WebPubSubServiceClient

public final class WebPubSubServiceClient

Initializes a new instance of the synchronous AzureWebPubSubServiceRestAPI type.

Method Summary

Modifier and Type Method and Description
void addConnectionsToGroups(List<String> groups, String filter)

Add filtered connections to multiple groups.

Response<Void> addConnectionToGroupWithResponse(String group, String connectionId, RequestOptions requestOptions)

Add a connection to the target group.

Response<Void> addUserToGroupWithResponse(String group, String userId, RequestOptions requestOptions)

Add a user to the target group.

Response<Boolean> checkPermissionWithResponse(WebPubSubPermission permission, String connectionId, RequestOptions requestOptions)

Check if a connection has permission to the specified action.

Response<Void> closeAllConnectionsWithResponse(RequestOptions requestOptions)

Close the connections in the hub.

Response<Void> closeConnectionWithResponse(String connectionId, RequestOptions requestOptions)

Close the client connection.

Response<Void> closeGroupConnectionsWithResponse(String group, RequestOptions requestOptions)

Close connections in the specific group.

Response<Void> closeUserConnectionsWithResponse(String userId, RequestOptions requestOptions)

Close connections for the specific user.

Response<Boolean> connectionExistsWithResponse(String connectionId, RequestOptions requestOptions)

Check if the connection with the given connectionId exists.

WebPubSubClientAccessToken getClientAccessToken(GetClientAccessTokenOptions options)

Creates a client access token.

Response<Void> grantPermissionWithResponse(WebPubSubPermission permission, String connectionId, RequestOptions requestOptions)

Grant permission to the connection.

Response<Boolean> groupExistsWithResponse(String group, RequestOptions requestOptions)

Check if there are any client connections inside the given group.

PagedIterable<WebPubSubGroupConnection> listConnectionsInGroup(String group, RequestOptions requestOptions)

List connections in a group.

Response<Void> removeConnectionFromAllGroupsWithResponse(String connectionId, RequestOptions requestOptions)

Remove a connection from all groups.

Response<Void> removeConnectionFromGroupWithResponse(String group, String connectionId, RequestOptions requestOptions)

Remove a connection from the target group.

Response<Void> removeUserFromAllGroupsWithResponse(String userId, RequestOptions requestOptions)

Remove a user from all groups.

Response<Void> removeUserFromGroupWithResponse(String group, String userId, RequestOptions requestOptions)

Remove a user from the target group.

Response<Void> revokePermissionWithResponse(WebPubSubPermission permission, String connectionId, RequestOptions requestOptions)

Revoke permission for the connection.

void sendToAll(String message, WebPubSubContentType contentType)

Broadcast content inside request body to all the connected client connections.

Response<Void> sendToAllWithResponse(BinaryData message, RequestOptions requestOptions)

Broadcast content inside request body to all the connected client connections.

Response<Void> sendToAllWithResponse(BinaryData message, WebPubSubContentType contentType, long contentLength, RequestOptions requestOptions)

Broadcast content inside request body to all the connected client connections.

void sendToConnection(String connectionId, String message, WebPubSubContentType contentType)

Send content inside request body to the specific connection.

Response<Void> sendToConnectionWithResponse(String connectionId, BinaryData message, RequestOptions requestOptions)

Send content inside request body to the specific connection.

Response<Void> sendToConnectionWithResponse(String connectionId, BinaryData message, WebPubSubContentType contentType, long contentLength, RequestOptions requestOptions)

Send content inside request body to the specific connection.

void sendToGroup(String group, String message, WebPubSubContentType contentType)

Send content inside request body to a group of connections.

Response<Void> sendToGroupWithResponse(String group, BinaryData message, RequestOptions requestOptions)

Send content inside request body to a group of connections.

Response<Void> sendToGroupWithResponse(String group, BinaryData message, WebPubSubContentType contentType, long contentLength, RequestOptions requestOptions)

Send content inside request body to a group of connections.

void sendToUser(String userId, String message, WebPubSubContentType contentType)

Send content inside request body to the specific user.

Response<Void> sendToUserWithResponse(String userId, BinaryData message, RequestOptions requestOptions)

Send content inside request body to the specific user.

Response<Void> sendToUserWithResponse(String userId, BinaryData message, WebPubSubContentType contentType, long contentLength, RequestOptions requestOptions)

Send content inside request body to the specific user.

Response<Boolean> userExistsWithResponse(String userId, RequestOptions requestOptions)

Check if there are any client connections connected for the given user.

Methods inherited from java.lang.Object

Method Details

addConnectionsToGroups

public void addConnectionsToGroups(List<String> groups, String filter)

Add filtered connections to multiple groups.

Request Body Schema

{
     groups: Iterable (Optional)
     filter: String (Optional)
 }

Parameters:

groups - Target group names. Rejected by server on status code 400 if this parameter is null.
filter - The filter to apply to the connections.

addConnectionToGroupWithResponse

public Response<Void> addConnectionToGroupWithResponse(String group, String connectionId, RequestOptions requestOptions)

Add a connection to the target group.

Parameters:

group - Target group name, which length should be greater than 0 and less than 1025.
connectionId - Target connection ID.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

addUserToGroupWithResponse

public Response<Void> addUserToGroupWithResponse(String group, String userId, RequestOptions requestOptions)

Add a user to the target group.

Parameters:

group - Target group name, which length should be greater than 0 and less than 1025.
userId - Target user ID.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

checkPermissionWithResponse

public Response<Boolean> checkPermissionWithResponse(WebPubSubPermission permission, String connectionId, RequestOptions requestOptions)

Check if a connection has permission to the specified action.

Parameters:

permission - The permission: current supported actions are joinLeaveGroup and sendToGroup.
connectionId - Target connection ID.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

closeAllConnectionsWithResponse

public Response<Void> closeAllConnectionsWithResponse(RequestOptions requestOptions)

Close the connections in the hub.

Query Parameters

| ---------- | ------ | -------- | -------------------------------------------------------------------- |
| Name       | Type   | Required | Description                                                          |
| excluded   | String | No       | Exclude these connectionIds when closing the connections in the hub. |
| reason     | String | No       | The reason closing the client connection.                            |
| apiVersion | String | Yes      | Api Version                                                          |

Parameters:

requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

closeConnectionWithResponse

public Response<Void> closeConnectionWithResponse(String connectionId, RequestOptions requestOptions)

Close the client connection.

Parameters:

connectionId - Target connection ID.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

closeGroupConnectionsWithResponse

public Response<Void> closeGroupConnectionsWithResponse(String group, RequestOptions requestOptions)

Close connections in the specific group.

Query Parameters

| ---------- | ------ | -------- | ---------------------------------------------------------------------- |
| Name       | Type   | Required | Description                                                            |
| excluded   | String | No       | Exclude these connectionIds when closing the connections in the group. |
| reason     | String | No       | The reason closing the client connection.                              |
| apiVersion | String | Yes      | Api Version                                                            |

Parameters:

group - Target group name, which length should be greater than 0 and less than 1025.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

closeUserConnectionsWithResponse

public Response<Void> closeUserConnectionsWithResponse(String userId, RequestOptions requestOptions)

Close connections for the specific user.

Query Parameters

| ---------- | ------ | -------- | ---------------------------------------------------------------------- |
| Name       | Type   | Required | Description                                                            |
| excluded   | String | No       | Exclude these connectionIds when closing the connections for the user. |
| reason     | String | No       | The reason closing the client connection.                              |
| apiVersion | String | Yes      | Api Version                                                            |

Parameters:

userId - The user ID.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

connectionExistsWithResponse

public Response<Boolean> connectionExistsWithResponse(String connectionId, RequestOptions requestOptions)

Check if the connection with the given connectionId exists.

Parameters:

connectionId - The connection ID.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

getClientAccessToken

public WebPubSubClientAccessToken getClientAccessToken(GetClientAccessTokenOptions options)

Creates a client access token.

Parameters:

options - Options to apply when creating the client access token.

Returns:

A new client access instance.

grantPermissionWithResponse

public Response<Void> grantPermissionWithResponse(WebPubSubPermission permission, String connectionId, RequestOptions requestOptions)

Grant permission to the connection.

Parameters:

permission - The permission: current supported actions are joinLeaveGroup and sendToGroup.
connectionId - Target connection ID.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

groupExistsWithResponse

public Response<Boolean> groupExistsWithResponse(String group, RequestOptions requestOptions)

Check if there are any client connections inside the given group.

Parameters:

group - Target group name, which length should be greater than 0 and less than 1025.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

listConnectionsInGroup

public PagedIterable<WebPubSubGroupConnection> listConnectionsInGroup(String group, RequestOptions requestOptions)

List connections in a group.

Query Parameters

| ----------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| Name        | Type    | Required | Description                                                                                                             |
| maxpagesize | Integer | No       | The maximum number of connections to include in a single response. It should be between 1 and 200.                      |
| top         | Integer | No       | The maximum number of connections to return. If the value is not set, then all the connections in a group are returned. |

You can add these to a request with RequestOptions#addQueryParam

Response Body Schema

{
     connectionId: String (Required)
     userId: String (Optional)
 }

Parameters:

group - Target group name, whose length should be greater than 0 and less than 1025.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

represents a page of elements as a LIST REST API result as paginated response with PagedIterable<T>.

removeConnectionFromAllGroupsWithResponse

public Response<Void> removeConnectionFromAllGroupsWithResponse(String connectionId, RequestOptions requestOptions)

Remove a connection from all groups.

Parameters:

connectionId - Target connection ID.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

removeConnectionFromGroupWithResponse

public Response<Void> removeConnectionFromGroupWithResponse(String group, String connectionId, RequestOptions requestOptions)

Remove a connection from the target group.

Parameters:

group - Target group name, which length should be greater than 0 and less than 1025.
connectionId - Target connection ID.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

removeUserFromAllGroupsWithResponse

public Response<Void> removeUserFromAllGroupsWithResponse(String userId, RequestOptions requestOptions)

Remove a user from all groups.

Parameters:

userId - Target user ID.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

removeUserFromGroupWithResponse

public Response<Void> removeUserFromGroupWithResponse(String group, String userId, RequestOptions requestOptions)

Remove a user from the target group.

Parameters:

group - Target group name, which length should be greater than 0 and less than 1025.
userId - Target user ID.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

revokePermissionWithResponse

public Response<Void> revokePermissionWithResponse(WebPubSubPermission permission, String connectionId, RequestOptions requestOptions)

Revoke permission for the connection.

Parameters:

permission - The permission: current supported actions are joinLeaveGroup and sendToGroup.
connectionId - Target connection ID.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

sendToAll

public void sendToAll(String message, WebPubSubContentType contentType)

Broadcast content inside request body to all the connected client connections.

Parameters:

message - The payload body.
contentType - Upload file type.

sendToAllWithResponse

public Response<Void> sendToAllWithResponse(BinaryData message, RequestOptions requestOptions)

Broadcast content inside request body to all the connected client connections.

Parameters:

message - The payload body.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

sendToAllWithResponse

public Response<Void> sendToAllWithResponse(BinaryData message, WebPubSubContentType contentType, long contentLength, RequestOptions requestOptions)

Broadcast content inside request body to all the connected client connections.

Parameters:

message - The payload body.
contentType - Upload file type.
contentLength - The contentLength parameter.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

sendToConnection

public void sendToConnection(String connectionId, String message, WebPubSubContentType contentType)

Send content inside request body to the specific connection.

Parameters:

connectionId - The connection ID.
message - The payload body.
contentType - Upload file type.

sendToConnectionWithResponse

public Response<Void> sendToConnectionWithResponse(String connectionId, BinaryData message, RequestOptions requestOptions)

Send content inside request body to the specific connection.

Parameters:

connectionId - The connection ID.
message - The payload body.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

sendToConnectionWithResponse

public Response<Void> sendToConnectionWithResponse(String connectionId, BinaryData message, WebPubSubContentType contentType, long contentLength, RequestOptions requestOptions)

Send content inside request body to the specific connection.

Parameters:

connectionId - The connection ID.
message - The payload body.
contentType - Upload file type.
contentLength - The contentLength parameter.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

sendToGroup

public void sendToGroup(String group, String message, WebPubSubContentType contentType)

Send content inside request body to a group of connections.

Parameters:

group - Target group name, which length should be greater than 0 and less than 1025.
message - The payload body.
contentType - Upload file type.

sendToGroupWithResponse

public Response<Void> sendToGroupWithResponse(String group, BinaryData message, RequestOptions requestOptions)

Send content inside request body to a group of connections.

Parameters:

group - Target group name, which length should be greater than 0 and less than 1025.
message - The payload body.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

sendToGroupWithResponse

public Response<Void> sendToGroupWithResponse(String group, BinaryData message, WebPubSubContentType contentType, long contentLength, RequestOptions requestOptions)

Send content inside request body to a group of connections.

Parameters:

group - Target group name, which length should be greater than 0 and less than 1025.
message - The payload body.
contentType - Upload file type.
contentLength - The contentLength parameter.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

sendToUser

public void sendToUser(String userId, String message, WebPubSubContentType contentType)

Send content inside request body to the specific user.

Parameters:

userId - The user ID.
message - The payload body.
contentType - Upload file type.

sendToUserWithResponse

public Response<Void> sendToUserWithResponse(String userId, BinaryData message, RequestOptions requestOptions)

Send content inside request body to the specific user.

Parameters:

userId - The user ID.
message - The payload body.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

sendToUserWithResponse

public Response<Void> sendToUserWithResponse(String userId, BinaryData message, WebPubSubContentType contentType, long contentLength, RequestOptions requestOptions)

Send content inside request body to the specific user.

Parameters:

userId - The user ID.
message - The payload body.
contentType - Upload file type.
contentLength - The contentLength parameter.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

userExistsWithResponse

public Response<Boolean> userExistsWithResponse(String userId, RequestOptions requestOptions)

Check if there are any client connections connected for the given user.

Parameters:

userId - Target user ID.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the response.

Applies to