public class WebSocketConnectionManager extends AppServiceBase<WebSocketConnectionManager>
Manage WebSocketConnection
through WebSocketConnectionRegistry
Destroyable.Util
Constructor and Description |
---|
WebSocketConnectionManager(App app) |
Modifier and Type | Method and Description |
---|---|
void |
registerNewConnection(WebSocketConnection connection,
ActionContext context) |
protected void |
releaseResources() |
void |
sendJsonToTagged(Object data,
Collection<String> labels)
Send JSON representation of given data object to all connections tagged with all give tag labels
|
void |
sendJsonToTagged(Object data,
String... labels)
Send JSON representation of given data object to all connections tagged with all give tag labels
|
void |
sendJsonToTagged(Object data,
String label)
Send JSON representation of given data object to all connections tagged with given label
|
void |
sendJsonToUrl(Object data,
String url)
Send JSON representation of given data object to all connections connected to given URL
|
void |
sendJsonToUser(Object data,
String username)
Send JSON representation of given data object to all connections of a user
|
void |
sendToTagged(String message,
Collection<String> labels)
Send message to all connections tagged with all given tags
|
void |
sendToTagged(String message,
String... labels)
Send message to all connections tagged with all given tags
|
void |
sendToTagged(String message,
String label)
Send message to all connections tagged with given label
|
void |
sendToUrl(String message,
String url)
Send message to all connections connected to give URL
|
void |
sendToUser(String message,
String username)
Send message to all connections of a user
|
WebSocketConnectionRegistry |
sessionRegistry() |
void |
subscribe(org.osgl.http.H.Session session,
String tag)
Add tag to any websocket connection linked to the session specified
|
WebSocketConnectionRegistry |
tagRegistry() |
WebSocketConnectionRegistry |
urlRegistry() |
WebSocketConnectionRegistry |
usernameRegistry() |
app
app, me
addSubResource, destroy, isDestroyed, reload, scope
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
destroy, isDestroyed, scope
public WebSocketConnectionManager(App app)
public WebSocketConnectionRegistry sessionRegistry()
public WebSocketConnectionRegistry usernameRegistry()
public WebSocketConnectionRegistry urlRegistry()
public WebSocketConnectionRegistry tagRegistry()
public void subscribe(org.osgl.http.H.Session session, String tag)
Add tag to any websocket connection linked to the session specified
session
- the session used to find websocket connectionstag
- the tag to subscribepublic void sendToUrl(String message, String url)
Send message to all connections connected to give URL
message
- the messageurl
- the urlpublic void sendJsonToUrl(Object data, String url)
Send JSON representation of given data object to all connections connected to given URL
data
- the data objecturl
- the urlpublic void sendToTagged(String message, String label)
Send message to all connections tagged with given label
message
- the messagelabel
- the tag labelpublic void sendToTagged(String message, String... labels)
Send message to all connections tagged with all given tags
message
- the messagelabels
- the tag labelspublic void sendToTagged(String message, Collection<String> labels)
Send message to all connections tagged with all given tags
message
- the messagelabels
- the tag labelspublic void sendJsonToTagged(Object data, String label)
Send JSON representation of given data object to all connections tagged with given label
data
- the data objectlabel
- the tag labelpublic void sendJsonToTagged(Object data, String... labels)
Send JSON representation of given data object to all connections tagged with all give tag labels
data
- the data objectlabels
- the tag labelspublic void sendJsonToTagged(Object data, Collection<String> labels)
Send JSON representation of given data object to all connections tagged with all give tag labels
data
- the data objectlabels
- the tag labelspublic void sendToUser(String message, String username)
Send message to all connections of a user
message
- the messageusername
- the usernamepublic void sendJsonToUser(Object data, String username)
Send JSON representation of given data object to all connections of a user
data
- the data objectusername
- the usernamepublic void registerNewConnection(WebSocketConnection connection, ActionContext context)
protected void releaseResources()
releaseResources
in class AppServiceBase<WebSocketConnectionManager>
Copyright © 2014-2017 ActFramework. All Rights Reserved.