public final class WebPubSubAsyncGroup extends Object
Async client for interacting with a specific Azure Web Pub Sub group, contained within a Azure Web Pub Sub hub.
An instance of this group client is able to be created by calling
WebPubSubAsyncServiceClient.getAsyncGroup(String)
on a WebPubSubAsyncServiceClient
instance. All operations
performed on an instance of a group client takes into account the specified group name, as well as the name of the
hub specified when instantiating the WebPubSubAsyncServiceClient
via the WebPubSubClientBuilder
. This is
demonstrated in the code below:
WebPubSubAsyncServiceClient client = new WebPubSubClientBuilder() .connectionString("<Insert connection string from Azure Portal>") .hub("chat-portal") .buildAsyncClient(); WebPubSubAsyncGroup adminGroup = client.getAsyncGroup("admins");
Modifier and Type | Method and Description |
---|---|
Mono<Void> |
addConnection(String connectionId)
Add a specific connection to this group.
|
Mono<com.azure.core.http.rest.Response<Void>> |
addConnectionWithResponse(String connectionId)
Add a specific connection to this group.
|
Mono<Void> |
addUser(String userId)
Add a user to this group that will remain in the group until they are manually removed.
|
Mono<com.azure.core.http.rest.Response<Void>> |
addUserWithResponse(String userId)
Add a user to this group.
|
Mono<Void> |
removeConnection(String connectionId)
Remove a specific connection from this group.
|
Mono<com.azure.core.http.rest.Response<Void>> |
removeConnectionWithResponse(String connectionId)
Remove a specific connection from this group.
|
Mono<Void> |
removeUser(String userId)
Remove a user from this group.
|
Mono<com.azure.core.http.rest.Response<Void>> |
removeUserWithResponse(String userId)
Remove a user from this group.
|
Mono<Void> |
sendToAll(byte[] message)
Broadcast a binary message to all connections in this group, excluding any connection IDs provided in the
excludedConnectionIds var-args (keeping in mind that it is valid to provide no excluded connection IDs). |
Mono<Void> |
sendToAll(byte[] message,
WebPubSubContentType contentType)
Broadcast a binary message to all connections in this group, excluding any connection IDs provided in the
excludedConnectionIds var-args (keeping in mind that it is valid to provide no excluded connection IDs). |
Mono<Void> |
sendToAll(String message)
Broadcast a text message to all connections in this group, excluding any connection IDs provided in the
excludedConnectionIds var-args (keeping in mind that it is valid to provide no excluded connection IDs). |
Mono<Void> |
sendToAll(String message,
WebPubSubContentType contentType)
Broadcast a text message to all connections in this group, excluding any connection IDs provided in the
excludedConnectionIds var-args (keeping in mind that it is valid to provide no excluded connection IDs). |
Mono<com.azure.core.http.rest.Response<Void>> |
sendToAllWithResponse(byte[] message,
WebPubSubContentType contentType,
Iterable<String> excludedConnectionIds)
Broadcast a binary message to all connections in this group, 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 in this group, excluding any connection IDs provided in the
excludedConnectionIds list. |
public Mono<Void> sendToAll(String message)
excludedConnectionIds
var-args (keeping in mind that it is valid to provide no excluded connection IDs).
Code Samples
To send a message to all users within the same group, with no exclusions, do the following:
groupClient.sendToAll("Hello world!").block();
message
- The message to send.Mono
containing a Response
with a null value, but status code and response headers
representing the response from the service.public Mono<Void> sendToAll(String message, WebPubSubContentType contentType)
excludedConnectionIds
var-args (keeping in mind that it is valid to provide no excluded connection IDs).
Code Samples
To send a message to all users within the same group, with no exclusions, do the following:
groupClient.sendToAll("Hello world!", WebPubSubContentType.TEXT_PLAIN).block();
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<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:
groupClient.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(); groupClient.sendToAllWithResponse("Hello world!", WebPubSubContentType.TEXT_PLAIN, 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> sendToAll(byte[] message)
excludedConnectionIds
var-args (keeping in mind that it is valid to provide no excluded connection IDs).
Code Samples
To send a binary message to all users within the same hub, with no exclusions, do the following:
groupClient.sendToAll("Hello world!".getBytes()).block();
message
- The binary message to send.Mono
.public Mono<Void> sendToAll(byte[] message, WebPubSubContentType contentType)
excludedConnectionIds
var-args (keeping in mind that it is valid to provide no excluded connection IDs).
Code Samples
To send a binary message to all users within the same hub, with no exclusions, do the following:
groupClient.sendToAll("Hello world!".getBytes(), WebPubSubContentType.APPLICATION_OCTET_STREAM).block();
message
- The binary 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:
groupClient.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 a list and as third parameter to this method.
List<String> excludedConnectionIds = getExcludedConnectionIds(); groupClient.sendToAllWithResponse("Hello world!".getBytes(), WebPubSubContentType.APPLICATION_OCTET_STREAM, excludedConnectionIds).block();
message
- The binary 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> addUser(String userId)
userId
- The user name to add.Mono
.public Mono<com.azure.core.http.rest.Response<Void>> addUserWithResponse(String userId)
userId
- The user name to addMono
containing a Response
with a null value, but status code and response headers
representing the response from the service.public Mono<Void> removeUser(String userId)
userId
- The user name to remove.Mono
.public Mono<com.azure.core.http.rest.Response<Void>> removeUserWithResponse(String userId)
userId
- The user name to remove.Mono
containing a Response
with a null value, but status code and response headers
representing the response from the service.public Mono<Void> addConnection(String connectionId)
connectionId
- The connection id to add to this group.Mono
.public Mono<com.azure.core.http.rest.Response<Void>> addConnectionWithResponse(String connectionId)
connectionId
- The connection id to add to this group.Mono
containing a Response
with a null value, but status code and response headers
representing the response from the service.public Mono<Void> removeConnection(String connectionId)
connectionId
- The connection id to remove from this group.Mono
.public Mono<com.azure.core.http.rest.Response<Void>> removeConnectionWithResponse(String connectionId)
connectionId
- The connection id to remove from this group.Mono
containing a Response
with a null value, but status code and response headers
representing the response from the service.Copyright © 2021 Microsoft Corporation. All rights reserved.