package com.cmvr.framework.websocket.handler;

import com.cmvr.framework.websocket.annotation.WSMessageType;
import com.cmvr.framework.websocket.enums.WSMessageTypeEnum;
import com.cmvr.framework.websocket.message.WSCommonMessage;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;

import java.io.IOException;

@WSMessageType(value = WSMessageTypeEnum.COMMON, messageClass = WSCommonMessage.class)
public class CommonMessageHandler implements WSMessageHandler<WSCommonMessage>{

    @Override
    public void handle(WebSocketSession session, WSCommonMessage message) throws IOException {
        System.out.println("common message: " + message.getContent());
        session.sendMessage(new TextMessage(message.getContent()));
    }
}
