Search in sources :

Example 1 with ConnectMessage

use of io.transport.core.protocol.message.internal.ConnectMessage in project transporter by wang4ever.

the class TransportMessageHandler method dispatch.

/**
 * 转发给具体业务方法
 *
 * 【方法描述】
 *
 * @param msg
 * @see: 【参考链接】
 */
@Override
protected void dispatch(ChannelHandlerContext ctx, Object msg) {
    // 1.1 请求连接
    if (msg instanceof ConnectMessage) {
        if (logger.isDebugEnabled())
            logger.debug("On connect. msg={}", msg);
        super.processAccpetConnect(ctx, (ConnectMessage) msg);
        return;
    }
    // 1.2 连接认证检查
    this.authentication();
    // 1.3 连接关闭
    if (msg instanceof ClosingMessage) {
        if (logger.isDebugEnabled())
            logger.debug("On close. msg={}", msg);
        // Close处理
        super.closeClient();
        return;
    }
    // 1.4 链路检测
    if (msg instanceof ActiveMessage) {
        if (logger.isDebugEnabled())
            logger.debug("On Active. msg={}", msg);
        // Reply client link detection.
        this.echoWrite(ctx, new ActiveRespMessage());
        return;
    } else // 1.5 消息传送
    if (msg instanceof TransportMessage) {
        if (logger.isDebugEnabled())
            logger.debug("On transport. msg={}", msg);
        // 数据传输处理
        this.processTransport(ctx, (TransportMessage) msg);
        return;
    } else // 1.6 注册前端设备
    if (msg instanceof DeviceRegistMessage) {
        if (logger.isDebugEnabled())
            logger.debug("On frontend device register. msg={}", msg);
        // 注册前端设备连接认证信息处理
        this.processDeviceRegisted(ctx, (DeviceRegistMessage) msg);
        return;
    }
    // 2.1 非法连接client close.
    this.closeClient();
    logger.warn("未知类型的消息.{}", JSON.toJSONString(msg));
    return;
}
Also used : ActiveRespMessage(io.transport.core.protocol.message.internal.ActiveRespMessage) ClosingMessage(io.transport.core.protocol.message.internal.ClosingMessage) ConnectMessage(io.transport.core.protocol.message.internal.ConnectMessage) ActiveMessage(io.transport.core.protocol.message.internal.ActiveMessage) DeviceRegistMessage(io.transport.core.protocol.message.internal.DeviceRegistMessage) TransportMessage(io.transport.core.protocol.message.internal.TransportMessage)

Aggregations

ActiveMessage (io.transport.core.protocol.message.internal.ActiveMessage)1 ActiveRespMessage (io.transport.core.protocol.message.internal.ActiveRespMessage)1 ClosingMessage (io.transport.core.protocol.message.internal.ClosingMessage)1 ConnectMessage (io.transport.core.protocol.message.internal.ConnectMessage)1 DeviceRegistMessage (io.transport.core.protocol.message.internal.DeviceRegistMessage)1 TransportMessage (io.transport.core.protocol.message.internal.TransportMessage)1