Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package org.emmanuel.spring.chat.handlers; import org.emmanuel.spring.chat.services.ChatRoomServices; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.handler.TextWebSocketHandler; /** * * @author u329022 */ public class ChatMessageHandler extends TextWebSocketHandler { @Autowired private ChatRoomServices chatRoomServices; public void OnOpen(WebSocketSession wss) throws Exception { chatRoomServices.onOpenConnection(wss, null); } public void onClose(WebSocketSession wss, CloseStatus status) throws Exception { chatRoomServices.onCloseConnection(wss, null); } public void onMessage(WebSocketSession wss, String message) throws Exception { chatRoomServices.onMessage(wss, message); } public void onError(WebSocketSession session, Throwable exception) throws Exception { chatRoomServices.onError(session); } }