public class WebSocketEndpoint
extends java.lang.Object
implements org.eclipse.jetty.websocket.WebSocket.OnTextMessage
org.eclipse.jetty.websocket.WebSocket.Connection, org.eclipse.jetty.websocket.WebSocket.FrameConnection, org.eclipse.jetty.websocket.WebSocket.OnBinaryMessage, org.eclipse.jetty.websocket.WebSocket.OnControl, org.eclipse.jetty.websocket.WebSocket.OnFrame, org.eclipse.jetty.websocket.WebSocket.OnTextMessage
Modifier and Type | Field and Description |
---|---|
(package private) java.lang.Exception |
_connectionException
An exception that might be thrown when connecting.
|
Constructor and Description |
---|
WebSocketEndpoint()
Create a new WebSocketEndpoint.
|
WebSocketEndpoint(WebSocketService service)
Create a new WebSocketEndpoint with the given parent service.
|
Modifier and Type | Method and Description |
---|---|
void |
addSubscriber(WebSocketService service)
Add a subscriber to this endpoint.
|
void |
close()
Close the connection.
|
int |
getSubscriberCount()
Return the number of subscribers this endpoint has.
|
boolean |
isOpen()
Return true if the connection is open; false otherwise.
|
void |
onClose(int statusCode,
java.lang.String statusMessage)
Upon close, set the connection to null.
|
void |
onMessage(java.lang.String message)
Notify subscribers about a new message.
|
void |
onOpen(org.eclipse.jetty.websocket.WebSocket.Connection connection)
Upon opening, save a reference to the connection.
|
void |
removeSubscriber(WebSocketService service)
Remove the given subscriber for this endpoint.
|
boolean |
sendMessage(java.lang.String message)
Send the given message.
|
java.lang.Exception _connectionException
public WebSocketEndpoint()
public WebSocketEndpoint(WebSocketService service)
service
- The WebSocketService to be notified of messages.public void addSubscriber(WebSocketService service)
service
- A parent WebSocketService of this endpoint.removeSubscriber(WebSocketService)
public void close()
public int getSubscriberCount()
public boolean isOpen()
public void onClose(int statusCode, java.lang.String statusMessage)
onClose
in interface org.eclipse.jetty.websocket.WebSocket
statusCode
- The status code of the closed connection.statusMessage
- The status message of the closed connection.onClose(int, String)
public void onMessage(java.lang.String message)
onMessage
in interface org.eclipse.jetty.websocket.WebSocket.OnTextMessage
message
- The message that was received.public void onOpen(org.eclipse.jetty.websocket.WebSocket.Connection connection)
onOpen
in interface org.eclipse.jetty.websocket.WebSocket
connection
- The connection that was opened.WebSocket.onOpen(Connection)
public void removeSubscriber(WebSocketService service)
service
- A parent WebSocketService of this endpoint.addSubscriber(WebSocketService)
public boolean sendMessage(java.lang.String message)
message
- The message to send.