All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.healthy.common.websocket.handler.PingJsonMessageHandler Maven / Gradle / Ivy

There is a newer version: 2.0.0-M1
Show newest version
package com.healthy.common.websocket.handler;

import com.healthy.common.websocket.WebSocketMessageSender;
import com.healthy.common.websocket.message.JsonWebSocketMessage;
import com.healthy.common.websocket.message.PingJsonWebSocketMessage;
import com.healthy.common.websocket.message.PongJsonWebSocketMessage;
import com.healthy.common.websocket.message.WebSocketMessageTypeEnum;
import org.springframework.web.socket.WebSocketSession;

/**
 * 心跳处理,接收到客户端的ping时,立刻回复一个pong
 *
 * @author xm.z
 */
public class PingJsonMessageHandler implements JsonMessageHandler {

	@Override
	public void handle(WebSocketSession session, PingJsonWebSocketMessage message) {
		JsonWebSocketMessage pongJsonWebSocketMessage = new PongJsonWebSocketMessage();
		WebSocketMessageSender.send(session, pongJsonWebSocketMessage);
	}

	@Override
	public String type() {
		return WebSocketMessageTypeEnum.PING.getValue();
	}

	@Override
	public Class getMessageClass() {
		return PingJsonWebSocketMessage.class;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy