package controllers.ws; |
|
|
| import javax.websocket.CloseReason; |
| import javax.websocket.Endpoint; |
| import javax.websocket.EndpointConfig; |
| import javax.websocket.MessageHandler; |
| import javax.websocket.Session; |
| import ninja.Context; |
| import ninja.Result; |
| import ninja.Results; |
| import ninja.websockets.WebSocketHandshake; |
|
|
| public class ChatWebSocket extends Endpoint implements MessageHandler.Whole { |
|
|
|
|
| public Result handshake(Context context, WebSocketHandshake handshake) { |
| try { |
| System.out.println("controllers.ws.ChatWebSocket.handshake()"); |
| return Results.webSocketContinue(); |
| } catch (Exception ex) { |
| ex.printStackTrace(); |
| return Results.webSocketContinue(); |
| } |
| } |
|
|
| @Override |
| public void onOpen(Session session, EndpointConfig arg1) { |
| System.out.println("controllers.ws.ChatWebSocket.onOpen()"); |
| } |
|
|
| @Override |
| public void onMessage(Object message) { |
| System.out.println("controllers.ws.ChatWebSocket.onMessage()"); |
| } |
|
|
| @Override |
| public void onClose(Session session, CloseReason closeReason) { |
| System.out.println("controllers.ws.ChatWebSocket.onClose()"); |
| super.onClose(session, closeReason); |
| } |
|
|
| @Override |
| public void onError(Session session, Throwable thr) { |
| System.out.println("controllers.ws.ChatWebSocket.onError()"); |
| super.onError(session, thr); |
| } |
|
|
| } |