Created
July 10, 2015 08:04
-
-
Save Kotlin-Native/94010df73d8b0960464e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MyWebSocketApplication extends WebSocketApplication { | |
| public boolean isApplicationRequest(Request request) { | |
| // determine if this application is responsible for this websocket request (identification by incoming request) | |
| return request.toString().contains("/mywebsocketapp/myspecializedsocket/do.connect"); | |
| } | |
| public WebSocket createWebSocket(ProtocolHandler protocolHandler, WebSocketListener... listeners) { | |
| // create a new WebSocket and add it to the list of Sockets hold by this app | |
| WebSocket socket = new MyWebSocket(protocolHandler, listeners); | |
| add(socket); | |
| return socket; | |
| } | |
| public void notifyOpenSockets(String message) { | |
| // call this method to send a message to all connected WebSockets of this app | |
| for (WebSocket socket: getWebSockets()) { | |
| if (socket.isConnected()) { | |
| socket.send(message); | |
| } | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment