public interface WSConnection
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close this connection with 1000 status which indicates a normal closure.
|
void |
close(int status,
String message)
Close this connection with specified status and message.
|
Object |
getAttribute(String name)
Returns the object bound with the specified name in this connection, or
null if no object is bound under the name. |
Collection<String> |
getChannels()
Get optional set of channels assigned for this connection.
|
int |
getCloseStatus()
Get connection close status.
|
javax.servlet.http.HttpSession |
getHttpSession()
Get HTTP session associated to this connection.
|
Long |
getId()
Get unique connection identifier.
|
javax.websocket.Session |
getWsSession() |
boolean |
isConnected()
Check connection state.
|
void |
registerMessageReceiver(WSMessageReceiver messageReceiver)
Register new WSMessageReceiver for this connection.
|
void |
removeAttribute(String name)
Removes the object bound with the specified name from this connection.
|
void |
removeMessageReceiver(WSMessageReceiver messageReceiver)
Unregister WSMessageReceiver.
|
void |
sendMessage(OutputMessage output)
Send message to client.
|
void |
setAttribute(String name,
Object value)
Binds an object to this connection, using the name specified.
|
boolean |
subscribeToChannel(String channel)
Subscribe this connection to specified channel.
|
boolean |
unsubscribeFromChannel(String channel)
Unsubscribe this connection from specified channel.
|
Long getId()
javax.servlet.http.HttpSession getHttpSession()
javax.websocket.Session getWsSession()
boolean subscribeToChannel(String channel)
channel - channel nametrue if this connection is subscribed to channel successfully and false if
connection already subscribed to specified channelWSConnectionContext.sendMessage(org.everrest.websockets.message.ChannelBroadcastMessage)boolean unsubscribeFromChannel(String channel)
channel - channel nametrue if this connection is unsubscribed from channel successfully and false if
connection is not subscribed to specified channelWSConnectionContext.sendMessage(org.everrest.websockets.message.ChannelBroadcastMessage)Collection<String> getChannels()
WSConnectionContext.sendMessage(org.everrest.websockets.message.ChannelBroadcastMessage)boolean isConnected()
true if connection is alive and false if connection already closed.int getCloseStatus()
0.0 if connection is alive or not opened yetvoid close()
throws IOException
IOException - if any i/o error occursvoid close(int status,
String message)
throws IOException
status - connection close statusmessage - optional messageIOException - if any i/o error occursvoid sendMessage(OutputMessage output) throws javax.websocket.EncodeException, IOException
output - output messagejavax.websocket.EncodeException - if message cannot be serializedIOException - if any i/o error occurs when try to send message to clientvoid registerMessageReceiver(WSMessageReceiver messageReceiver)
messageReceiver - message receivervoid removeMessageReceiver(WSMessageReceiver messageReceiver)
messageReceiver - message receiverObject getAttribute(String name)
null if no object is bound under the name.name - a string specifying the name of the objectvoid setAttribute(String name, Object value)
name - the name to which the object is bound; cannot be nullvalue - the object to be boundvoid removeAttribute(String name)
name - the name of the object to remove from this connectionCopyright © 2012–2016 Codenvy, S.A.. All rights reserved.