package com.mortals.xhx.base.framework.ws.handler;

import com.mortals.xhx.base.framework.ws.message.HeartBeatRequest;
import com.mortals.xhx.base.framework.ws.message.SendResponse;
import com.mortals.xhx.base.framework.ws.util.WebSocketUtil;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketSession;

@Component
public class HeartBeatHandler implements MessageHandler<HeartBeatRequest> {

    @Override
    public void execute(WebSocketSession session, HeartBeatRequest message) {
        // 这里，假装直接成功
        SendResponse sendResponse = new SendResponse().setMsgId(message.getMsgId()).setCode(0);
        WebSocketUtil.send(session, SendResponse.TYPE, sendResponse);
    }

    @Override
    public String getType() {
        return HeartBeatRequest.TYPE;
    }

}
