public final class WebPubSubAsyncServiceClient extends Object
WebPubSubServiceClient
class documentation). To create an instance of this class, refer to the code snippet
below, and for more information about configuration options, refer to the JavaDoc for WebPubSubClientBuilder
.
The Azure Web Pub Sub client instance must be connected to a
specific hub
that is represented by a non-null and non-empty String.
Within the Azure Web Pub Sub client, users may perform operations including:
everyone in the hub
,specific user
or
connection
,Removing a user
from all groups,Closing a connection
of a specific useruser
, a
connection
, or a group
,It is possible to connect to a specific group within a hub by calling
WebPubSubAsyncServiceClient.getAsyncGroup(String)
, which will return a WebPubSubAsyncGroup
. All operations performed
on this Azure Web Pub Sub group client will take into account the hub and group in which it exists.
Code Samples
WebPubSubAsyncServiceClient client = new WebPubSubClientBuilder() .connectionString("<Insert connection string from Azure Portal>") .buildAsyncClient();
Modifier and Type | Method and Description |
---|---|
Mono<Boolean> |
checkConnectionExists(String connectionId)
Check if a specific connection is connected to this hub.
|
Mono<com.azure.core.http.rest.Response<Boolean>> |
checkConnectionExistsWithResponse(String connectionId)
Check if a specific connection is connected to this hub.
|
Mono<Boolean> |
checkGroupExists(String group)
Check if a particular group exists (i.e.
|
Mono<com.azure.core.http.rest.Response<Boolean>> |
checkGroupExistsWithResponse(String group)
Check if a particular group exists (i.e.
|
Mono<Boolean> |
checkPermissionExists(WebPubSubPermission permission,
String connectionId,
String targetName)
Check if a connection has permission to the specified action.
|
Mono<com.azure.core.http.rest.Response<Boolean>> |
checkPermissionExistsWithResponse(WebPubSubPermission permission,
String connectionId,
String targetName)
Check if a connection has permission to the specified action.
|
Mono<Boolean> |
checkUserExists(String userId)
Check if a particular user is connected to this hub.
|
Mono<com.azure.core.http.rest.Response<Boolean>> |
checkUserExistsWithResponse(String userId)
Check if a particular user is connected to this hub.
|
Mono<Void> |
closeConnection(String connectionId)
Close a specific connection to this hub.
|
Mono<com.azure.core.http.rest.Response<Void>> |
closeConnectionWithResponse(String connectionId,
String reason)
Close a specific connection to this hub.
|
WebPubSubAsyncGroup |
getAsyncGroup(String group)
Creates a new asynchronous
WebPubSubGroup for connecting to a specified
Azure Web Pub Sub group, which will also remain associated with the hub that was previously specified for the
calling client instance in its builder (set via WebPubSubClientBuilder.hub(String) . |
WebPubSubAuthenticationToken |
getAuthenticationToken(GetAuthenticationTokenOptions options)
Creates an authentication token.
|
Mono<Void> |
grantPermission(WebPubSubPermission permission,
String connectionId)
Grant permission to the specified connection.
|
Mono<com.azure.core.http.rest.Response<Void>> |
grantPermissionWithResponse(WebPubSubPermission permission,
String connectionId,
String targetName)
Grant permission to the specified connection.
|
Mono<Void> |
removeUserFromAllGroups(String userId)
Remove a specific user from all groups they are joined to.
|
Mono<com.azure.core.http.rest.Response<Void>> |
removeUserFromAllGroupsWithResponse(String userId)
Remove a specific user from all groups they are joined to.
|
Mono<Void> |
revokePermission(WebPubSubPermission permission,
String connectionId)
Revoke permission for the specified connection.
|
Mono<com.azure.core.http.rest.Response<Void>> |
revokePermissionWithResponse(WebPubSubPermission permission,
String connectionId,
String targetName)
Revoke permission for the specified connection.
|
Mono<Void> |
sendToAll(byte[] message)
Broadcast a binary message to all connections on this hub.
|
Mono<Void> |
sendToAll(byte[] message,
WebPubSubContentType contentType)
Broadcast a binary message to all connections on this hub.
|
Mono<Void> |
sendToAll(String message)
Broadcast a text message to all connections on this hub.
|
Mono<Void> |
sendToAll(String message,
WebPubSubContentType contentType)
Broadcast a text message to all connections on this hub.
|
Mono<com.azure.core.http.rest.Response<Void>> |
sendToAllWithResponse(byte[] message,
WebPubSubContentType contentType,
Iterable<String> excludedConnectionIds)
Broadcast a binary message to all connections on this hub, excluding any connection IDs provided in the
excludedConnectionIds list. |
Mono<com.azure.core.http.rest.Response<Void>> |
sendToAllWithResponse(String message,
WebPubSubContentType contentType,
Iterable<String> excludedConnectionIds)
Broadcast a text message to all connections on this hub, excluding any connection IDs provided in the
excludedConnectionIds list. |
Mono<Void> |
sendToConnection(String connectionId,
byte[] message)
Send a binary message to a specific connection
|
Mono<Void> |
sendToConnection(String connectionId,
byte[] message,
WebPubSubContentType contentType)
Send a binary message to a specific connection
|
Mono<Void> |
sendToConnection(String connectionId,
String message)
Send a message to a specific connection
|
Mono<Void> |
sendToConnection(String connectionId,
String message,
WebPubSubContentType contentType)
Send a message to a specific connection
|
Mono<com.azure.core.http.rest.Response<Void>> |
sendToConnectionWithResponse(String connectionId,
byte[] message,
WebPubSubContentType contentType)
Send a binary message to a specific connection
|
Mono<com.azure.core.http.rest.Response<Void>> |
sendToConnectionWithResponse(String connectionId,
String message,
WebPubSubContentType contentType)
Send a message to a specific connection
|
Mono<Void> |
sendToUser(String userId,
byte[] message)
Send a binary message to a specific user.
|
Mono<Void> |
sendToUser(String userId,
byte[] message,
WebPubSubContentType contentType)
Send a binary message to a specific user.
|
Mono<Void> |
sendToUser(String userId,
String message)
Send a text message to a specific user.
|
Mono<Void> |
sendToUser(String userId,
String message,
WebPubSubContentType contentType)
Send a text message to a specific user.
|
Mono<com.azure.core.http.rest.Response<Void>> |
sendToUserWithResponse(String userId,
byte[] message,
WebPubSubContentType contentType)
Send a binary message to a specific user.
|
Mono<com.azure.core.http.rest.Response<Void>> |
sendToUserWithResponse(String userId,
String message,
WebPubSubContentType contentType)
Send a text message to a specific user.
|
public WebPubSubAsyncGroup getAsyncGroup(String group)
WebPubSubGroup
for connecting to a specified
Azure Web Pub Sub group, which will also remain associated with the hub that was previously specified for the
calling client instance in its builder (set via WebPubSubClientBuilder.hub(String)
.group
- The name of the group.public WebPubSubAuthenticationToken getAuthenticationToken(GetAuthenticationTokenOptions options)
options
- Options to apply when creating the authentication token.public Mono<Void> sendToAll(String message)
Code Samples
To send a message to all users within the same hub, with no exclusions, do the following:
client.sendToAll("Hello world!").block();
message
- The message to send.Mono
.public Mono<Void> sendToAll(String message, WebPubSubContentType contentType)
Code Samples
To send a message to all users within the same hub, with no exclusions, do the following:
client.sendToAll("Hello world!", WebPubSubContentType.TEXT_PLAIN).block();
message
- The message to send.contentType
- The content type of the message.Mono
.public Mono<com.azure.core.http.rest.Response<Void>> sendToAllWithResponse(String message, WebPubSubContentType contentType, Iterable<String> excludedConnectionIds)
excludedConnectionIds
list.
Code Samples
To send a message to all users within the same hub, with no exclusions, do the following:
client.sendToAllWithResponse("Hello world!", WebPubSubContentType.TEXT_PLAIN, Collections.emptyList()).block();
To send a message to all users within the same hub, with one or more connection IDs excluded, simply add the excluded connection IDs to a List and pass that in as the third argument:
List<String> excludedConnectionIds = getExcludedConnectionIds(); client.sendToAllWithResponse("Hello world!", WebPubSubContentType.TEXT_PLAIN, excludedConnectionIds).block();
message
- The message to send.contentType
- The content type of the message.excludedConnectionIds
- An optional iterable of connection IDs to not broadcast the message to.Mono
containing a Response
with a null value, but status code and response headers
representing the response from the service.public Mono<Void> sendToAll(byte[] message)
Code Samples
To send a binary message to all users within the same hub, with no exclusions, do the following:
client.sendToAll("Hello world!".getBytes()).block();
message
- The message to send.Mono
.public Mono<Void> sendToAll(byte[] message, WebPubSubContentType contentType)
Code Samples
To send a binary message to all users within the same hub, with no exclusions, do the following:
client.sendToAll("Hello world!".getBytes(), WebPubSubContentType.APPLICATION_OCTET_STREAM).block();
message
- The message to send.contentType
- The content type of the message.Mono
.public Mono<com.azure.core.http.rest.Response<Void>> sendToAllWithResponse(byte[] message, WebPubSubContentType contentType, Iterable<String> excludedConnectionIds)
excludedConnectionIds
list.
Code Samples
To send a binary message to all users within the same hub, with no exclusions, do the following:
client.sendToAllWithResponse("Hello world!".getBytes(), WebPubSubContentType.APPLICATION_OCTET_STREAM, Collections.emptyList()).block();
To send a binary message to all users within the same hub, with one or more connection IDs excluded, simply add the excluded connection IDs to the end of the method call as var-args:
List<String> excludedConnectionIds = getExcludedConnectionIds(); client.sendToAllWithResponse("Hello world!".getBytes(), WebPubSubContentType.APPLICATION_OCTET_STREAM, excludedConnectionIds).block();
message
- The message to send.contentType
- The content type of the message.excludedConnectionIds
- An optional list of connection IDs to not broadcast the message to.Mono
containing a Response
with a null value, but status code and response headers
representing the response from the service.public Mono<Void> sendToUser(String userId, String message)
userId
- User name to send to.message
- The message to send.Mono
.public Mono<Void> sendToUser(String userId, String message, WebPubSubContentType contentType)
userId
- User name to send to.message
- The message to send.contentType
- The content type of the message.Mono
.public Mono<com.azure.core.http.rest.Response<Void>> sendToUserWithResponse(String userId, String message, WebPubSubContentType contentType)
userId
- User name to send to.message
- The message to send.contentType
- The content type of the message.Mono
containing a Response
with a null value, but status code and response headers
representing the response from the service.public Mono<Void> sendToUser(String userId, byte[] message)
userId
- User name to send to.message
- The binary message to send.Mono
.public Mono<Void> sendToUser(String userId, byte[] message, WebPubSubContentType contentType)
userId
- User name to send to.message
- The binary message to send.contentType
- The content type of the message.Mono
.public Mono<com.azure.core.http.rest.Response<Void>> sendToUserWithResponse(String userId, byte[] message, WebPubSubContentType contentType)
userId
- User name to send to.message
- The binary message to send.contentType
- The content type of the message.Mono
containing a Response
with a null value, but status code and response headers
representing the response from the service.public Mono<Void> sendToConnection(String connectionId, String message)
connectionId
- Connection ID to send to.message
- The message to send.Mono
.public Mono<Void> sendToConnection(String connectionId, String message, WebPubSubContentType contentType)
connectionId
- Connection ID to send to.message
- The message to send.contentType
- The content type of the message.Mono
.public Mono<com.azure.core.http.rest.Response<Void>> sendToConnectionWithResponse(String connectionId, String message, WebPubSubContentType contentType)
connectionId
- Connection ID to send to.message
- The message to send.contentType
- The content type of the message.Mono
containing a Response
with a null value, but status code and response headers
representing the response from the service.public Mono<Void> sendToConnection(String connectionId, byte[] message)
connectionId
- Connection ID to send to.message
- The binary message to send.Mono
.public Mono<Void> sendToConnection(String connectionId, byte[] message, WebPubSubContentType contentType)
connectionId
- Connection ID to send to.message
- The binary message to send.contentType
- The content type of the message.Mono
.public Mono<com.azure.core.http.rest.Response<Void>> sendToConnectionWithResponse(String connectionId, byte[] message, WebPubSubContentType contentType)
connectionId
- Connection ID to send to.message
- The binary message to send.contentType
- The content type of the message.Mono
containing a Response
with a null value, but status code and response headers
representing the response from the service.public Mono<Void> removeUserFromAllGroups(String userId)
userId
- The user ID to remove from all groups.Mono
.public Mono<com.azure.core.http.rest.Response<Void>> removeUserFromAllGroupsWithResponse(String userId)
userId
- The user ID to remove from all groups.Mono
containing a Response
with a null value, but status code and response headers
representing the response from the service.public Mono<Boolean> checkUserExists(String userId)
userId
- The user name to check for.Mono
containing a Response
with a Boolean value representing whether the user exists in
this hub, as well as status code and response headers representing the response from the service.public Mono<com.azure.core.http.rest.Response<Boolean>> checkUserExistsWithResponse(String userId)
userId
- The user name to check for.Mono
containing a Response
with a Boolean value representing whether the user exists in
this hub, as well as status code and response headers representing the response from the service.public Mono<Boolean> checkGroupExists(String group)
group
- The group name to check for.Mono
containing a Response
with a Boolean value representing whether the group exists,
as well as status code and response headers representing the response from the service.public Mono<com.azure.core.http.rest.Response<Boolean>> checkGroupExistsWithResponse(String group)
group
- The group name to check for.Mono
containing a Response
with a Boolean value representing whether the group exists,
as well as status code and response headers representing the response from the service.public Mono<Void> closeConnection(String connectionId)
connectionId
- Connection ID to close.Mono
containing a Response
with a null value, but status code and response headers
representing the response from the service.public Mono<com.azure.core.http.rest.Response<Void>> closeConnectionWithResponse(String connectionId, String reason)
connectionId
- Connection ID to close.reason
- The reason why the connection was closed.Mono
containing a Response
with a null value, but status code and response headers
representing the response from the service.public Mono<Boolean> checkConnectionExists(String connectionId)
connectionId
- Connection ID to check.Mono
containing a Response
with a Boolean value representing whether the connection
exists in this hub, as well as status code and response headers representing the response from the service.public Mono<com.azure.core.http.rest.Response<Boolean>> checkConnectionExistsWithResponse(String connectionId)
connectionId
- Connection ID to check.Mono
containing a Response
with a Boolean value representing whether the connection
exists in this hub, as well as status code and response headers representing the response from the service.public Mono<Boolean> checkPermissionExists(WebPubSubPermission permission, String connectionId, String targetName)
permission
- The permission to be checked against the given connection ID.connectionId
- Target connection Id.targetName
- Get the permission for the specific target. The meaning of the target depends on the
specific permission.Mono
containing a Response
with a Boolean value representing whether the connection
has the specified permission.public Mono<com.azure.core.http.rest.Response<Boolean>> checkPermissionExistsWithResponse(WebPubSubPermission permission, String connectionId, String targetName)
permission
- The permission to be checked against the given connection ID.connectionId
- Target connection Id.targetName
- Get the permission for the specific target. The meaning of the target depends on the
specific permission.Mono
containing a Response
with a Boolean value representing whether the connection
has the specified permission, as well as status code and response headers representing the response from
the service.public Mono<Void> grantPermission(WebPubSubPermission permission, String connectionId)
permission
- The permission to be granted to the given connection ID.connectionId
- Target connection ID.Mono
containing a void Response
, enabling retrieval of the status code and response
headers from the service.public Mono<com.azure.core.http.rest.Response<Void>> grantPermissionWithResponse(WebPubSubPermission permission, String connectionId, String targetName)
permission
- The permission to be granted to the given connection ID.connectionId
- Target connection ID.targetName
- The specific target that will have the permission granted.Mono
containing a void Response
, enabling retrieval of the status code and response
headers from the service.public Mono<Void> revokePermission(WebPubSubPermission permission, String connectionId)
permission
- The permission to be revoked.connectionId
- Target connection ID.Mono
containing a void Response
, enabling retrieval of the status code and response
headers from the service.public Mono<com.azure.core.http.rest.Response<Void>> revokePermissionWithResponse(WebPubSubPermission permission, String connectionId, String targetName)
permission
- The permission to be revoked.connectionId
- Target connection ID.targetName
- Revoke the permission for the specific target.Mono
containing a void Response
, enabling retrieval of the status code and response
headers from the service.Copyright © 2021 Microsoft Corporation. All rights reserved.