All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.websockets.next.WebSocketConnection Maven / Gradle / Ivy

There is a newer version: 3.17.2
Show newest version
package io.quarkus.websockets.next;

import java.util.Set;
import java.util.function.Predicate;

import io.smallrye.common.annotation.Experimental;

/**
 * This interface represents a connection from a client to a specific {@link WebSocket} endpoint on the server.
 * 

* Quarkus provides a CDI bean that implements this interface and can be injected in a {@link WebSocket} * endpoint and used to interact with the connected client, or all clients connected to the endpoint respectively * (broadcasting). *

* Specifically, it is possible to send messages using blocking and non-blocking methods, declared on * {@link BlockingSender} and {@link Sender} respectively. */ @Experimental("This API is experimental and may change in the future") public interface WebSocketConnection extends Connection { /** * * @return the endpoint id * @see WebSocket#endpointId() */ String endpointId(); /** * Sends messages to all open clients connected to the same WebSocket endpoint. * * @return the broadcast sender * @see #getOpenConnections() */ BroadcastSender broadcast(); /** * The returned set also includes the connection this method is called upon. * * @return the set of open connections to the same endpoint */ Set getOpenConnections(); /** * * @return the subprotocol selected by the handshake */ String subprotocol(); /** * Makes it possible to send messages to all clients connected to the same WebSocket endpoint. * * @see WebSocketConnection#getOpenConnections() */ interface BroadcastSender extends BlockingSender { /** * * @param predicate * @return a new sender that sends messages to all open clients connected to the same WebSocket endpoint and matching * the given filter predicate */ BroadcastSender filter(Predicate predicate); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy