public class TyrusEndpointWrapper extends Object
TyrusEndpointWrapper
for each application class, which handles all the methods.Modifier and Type | Class and Description |
---|---|
static interface |
TyrusEndpointWrapper.OnCloseListener
Close listener.
|
Constructor and Description |
---|
TyrusEndpointWrapper(Class<? extends Endpoint> endpointClass,
EndpointConfig configuration,
ComponentProviderService componentProvider,
WebSocketContainer container,
String contextPath,
ServerEndpointConfig.Configurator configurator)
Create
TyrusEndpointWrapper for class that extends Endpoint . |
TyrusEndpointWrapper(Endpoint endpoint,
EndpointConfig configuration,
ComponentProviderService componentProvider,
WebSocketContainer container,
String contextPath,
ServerEndpointConfig.Configurator configurator,
TyrusEndpointWrapper.OnCloseListener onCloseListener,
ClusterContext clusterContext)
|
Modifier and Type | Method and Description |
---|---|
Map<Session,Future<?>> |
broadcast(ByteBuffer message)
Broadcasts binary message to all connected clients.
|
Map<Session,Future<?>> |
broadcast(String message)
Broadcasts text message to all connected clients.
|
Session |
createSessionForRemoteEndpoint(TyrusWebSocket socket,
String subprotocol,
List<Extension> extensions)
Creates a Session based on the
TyrusWebSocket , subprotocols and extensions. |
TyrusWebSocket |
createSocket(ProtocolHandler handler)
Factory method to create new
TyrusWebSocket instances. |
Object |
doEncode(Session session,
Object message) |
EndpointConfig |
getEndpointConfig()
Get Endpoint configuration.
|
String |
getEndpointPath()
Get Endpoint absolute path.
|
List<Extension> |
getNegotiatedExtensions(List<Extension> clientExtensions)
Server-side; Get the negotiated extensions' names based on the extensions supported by client.
|
String |
getNegotiatedProtocol(List<String> clientProtocols)
Server-side; Compute the sub-protocol which will be used.
|
Set<Session> |
getOpenSessions(TyrusSession tyrusSession)
Get the endpoint's open
Session s. |
void |
onClose(TyrusWebSocket socket,
CloseReason closeReason)
Called by the provider when the web socket connection
to the given remote endpoint has just closed.
|
Session |
onConnect(TyrusWebSocket socket,
UpgradeRequest upgradeRequest,
String subProtocol,
List<Extension> extensions,
String connectionId)
Called by the provider when the web socket connection
is established.
|
boolean |
onError(TyrusWebSocket socket,
Throwable t)
This method will be invoked if an unexpected exception is caught by
the WebSocket runtime.
|
void |
onHandShakeResponse(UpgradeRequest request,
UpgradeResponse response)
Invoked when server side handshake is ready to send response.
|
void |
onMessage(TyrusWebSocket socket,
ByteBuffer messageBytes)
Called by the provider when the web socket connection
has an incoming text message from the given remote endpoint.
|
void |
onMessage(TyrusWebSocket socket,
String messageString)
Called by the provider when the web socket connection
has an incoming text message from the given remote endpoint.
|
void |
onPartialMessage(TyrusWebSocket socket,
ByteBuffer partialBytes,
boolean last)
Called by the provider when the web socket connection
has an incoming partial binary message from the given remote endpoint.
|
void |
onPartialMessage(TyrusWebSocket socket,
String partialString,
boolean last)
Called by the provider when the web socket connection
has an incoming partial text message from the given remote endpoint.
|
void |
onPing(TyrusWebSocket socket,
ByteBuffer bytes)
Called by the provider when the web socket connection
has an incoming ping message from the given remote endpoint.
|
void |
onPong(TyrusWebSocket socket,
ByteBuffer bytes)
Called by the provider when the web socket connection
has an incoming pong message from the given remote endpoint.
|
String |
toString() |
boolean |
upgrade(UpgradeRequest request)
Server side check for protocol specific information to determine whether the request can be upgraded.
|
public TyrusEndpointWrapper(Class<? extends Endpoint> endpointClass, EndpointConfig configuration, ComponentProviderService componentProvider, WebSocketContainer container, String contextPath, ServerEndpointConfig.Configurator configurator) throws DeploymentException
TyrusEndpointWrapper
for class that extends Endpoint
.endpointClass
- endpoint class for which the wrapper is created.configuration
- endpoint configuration.componentProvider
- component provider.container
- container where the wrapper is running.DeploymentException
public TyrusEndpointWrapper(Endpoint endpoint, EndpointConfig configuration, ComponentProviderService componentProvider, WebSocketContainer container, String contextPath, ServerEndpointConfig.Configurator configurator, TyrusEndpointWrapper.OnCloseListener onCloseListener, ClusterContext clusterContext) throws DeploymentException
endpoint
- endpoint instance for which the wrapper is created.configuration
- endpoint configuration.componentProvider
- component provider.container
- container where the wrapper is running.clusterContext
- cluster context instance. null
indicates standalone mode.DeploymentException
public String getEndpointPath()
public Object doEncode(Session session, Object message) throws EncodeException, IOException
EncodeException
IOException
public List<Extension> getNegotiatedExtensions(List<Extension> clientExtensions)
clientExtensions
- names of the extensions' supported by client.public String getNegotiatedProtocol(List<String> clientProtocols)
clientProtocols
- sub-protocols supported by client.null
if none found.public Set<Session> getOpenSessions(TyrusSession tyrusSession)
Session
s.tyrusSession
- only for clustering purpose (local encoder will be used when needed).public Session createSessionForRemoteEndpoint(TyrusWebSocket socket, String subprotocol, List<Extension> extensions)
TyrusWebSocket
, subprotocols and extensions.socket
- the other end of the connection.subprotocol
- used.extensions
- extensions used.Session
representing the connection.public Session onConnect(TyrusWebSocket socket, UpgradeRequest upgradeRequest, String subProtocol, List<Extension> extensions, String connectionId)
socket
- TyrusWebSocket
who has just connected to this web socket endpoint.upgradeRequest
- request associated with accepted connection.public void onMessage(TyrusWebSocket socket, ByteBuffer messageBytes)
socket
- TyrusWebSocket
who sent the message.messageBytes
- the message.public void onMessage(TyrusWebSocket socket, String messageString)
socket
- TyrusWebSocket
who sent the message.messageString
- the message.public void onPartialMessage(TyrusWebSocket socket, String partialString, boolean last)
socket
- TyrusWebSocket
who sent the message.partialString
- the String message.last
- to indicate if this is the last partial string in the sequencepublic void onPartialMessage(TyrusWebSocket socket, ByteBuffer partialBytes, boolean last)
socket
- TyrusWebSocket
who sent the message.partialBytes
- the piece of the binary message.last
- to indicate if this is the last partial byte buffer in the sequencepublic void onPong(TyrusWebSocket socket, ByteBuffer bytes)
socket
- TyrusWebSocket
who sent the message.bytes
- the message.public void onPing(TyrusWebSocket socket, ByteBuffer bytes)
socket
- TyrusWebSocket
who sent the message.bytes
- the message.public void onClose(TyrusWebSocket socket, CloseReason closeReason)
socket
- TyrusWebSocket
who has just closed the connection.public EndpointConfig getEndpointConfig()
public Map<Session,Future<?>> broadcast(String message)
message
- message to be broadcasted.public Map<Session,Future<?>> broadcast(ByteBuffer message)
message
- message to be broadcasted.public final boolean upgrade(UpgradeRequest request)
Upgrade
header with a value of WebSocket
.request
- TODOtrue
if the request should be upgraded to a
WebSocket connectionpublic TyrusWebSocket createSocket(ProtocolHandler handler)
TyrusWebSocket
instances. Developers may
wish to override this to return customized TyrusWebSocket
implementations.handler
- the ProtocolHandler
to use with the newly created
TyrusWebSocket
.public boolean onError(TyrusWebSocket socket, Throwable t)
socket
- the websocket being processed at the time the
exception occurred.t
- the unexpected exception.true
if the WebSocket should be closed otherwise
false
.public void onHandShakeResponse(UpgradeRequest request, UpgradeResponse response)
request
- original request which caused this handshake.response
- response to be send.Copyright © 2012-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.