Package org.spincast.core.websocket
Interface WebsocketContext<W extends WebsocketContext<?>>
- All Known Subinterfaces:
AppWebsocketContext
,DefaultWebsocketContext
- All Known Implementing Classes:
AppWebsocketContextDefault
,DefaultWebsocketContextDefault
public interface WebsocketContext<W extends WebsocketContext<?>>
The base interface for a WebSocket context.
A WebSocket context is the object passed to a WebSocket
controller when an event for a particular peer occured.
For example when a message is sent from a peer, or if
the peer closed the WebSocket connection.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Closes the connection with the current peer.<T> T
get
(com.google.inject.Key<T> key) Shortcut to get an instance from Guice.<T> T
Shortcut to get an instance from Guice.The id of the endpointThe best Locale to use, as resolved by theLocaleResolver
during the initial HTTP request.The id of the peer.The best TimeZone to use, as resolved by theTimeZoneResolver
.com.google.inject.Injector
guice()
Easy access to the Guice context.json()
Easy access to theJsonManager
, Json related methods.void
sendMessageToCurrentPeer
(byte[] message) Sends a byte array message to the current peer.void
sendMessageToCurrentPeer
(String message) Sends a String message to the current peer.Easy access to theTemplatingEngine
, templating related methods.xml()
Easy access to theXmlManager
, XML related methods.
-
Method Details
-
getEndpointId
String getEndpointId()The id of the endpoint -
getPeerId
String getPeerId()The id of the peer. -
sendMessageToCurrentPeer
Sends a String message to the current peer. Same as WebsocketEndpointManager#sendMessage(getPeerId(), message) -
sendMessageToCurrentPeer
void sendMessageToCurrentPeer(byte[] message) Sends a byte array message to the current peer. Same as WebsocketEndpointManager#sendMessage(getPeerId(), message) -
closeConnectionWithCurrentPeer
void closeConnectionWithCurrentPeer()Closes the connection with the current peer. Same as WebsocketEndpointManager#closePeer(getPeerId()) -
json
JsonManager json()Easy access to theJsonManager
, Json related methods. -
xml
XmlManager xml()Easy access to theXmlManager
, XML related methods. -
templating
TemplatingEngine templating()Easy access to theTemplatingEngine
, templating related methods. -
guice
com.google.inject.Injector guice()Easy access to the Guice context. -
get
Shortcut to get an instance from Guice. Will also cache the instance (as long as it is request scoped or a singleton). -
get
<T> T get(com.google.inject.Key<T> key) Shortcut to get an instance from Guice. Will also cache the instance (as long as it is request scoped or a singleton) -
getLocaleToUse
Locale getLocaleToUse()The best Locale to use, as resolved by theLocaleResolver
during the initial HTTP request. -
getTimeZoneToUse
TimeZone getTimeZoneToUse()The best TimeZone to use, as resolved by theTimeZoneResolver
.
-