Java 类io.netty.handler.codec.UnsupportedMessageTypeException 实例源码

项目:WebInterface    文件:WebSocketConnection.java   
@Override
protected void channelRead0(ChannelHandlerContext context, WebSocketFrame frame) throws Exception {
    if(frame instanceof CloseWebSocketFrame){
        handshaker.close(context.channel(), (CloseWebSocketFrame) frame.retain());
        return;
    }
    if(frame instanceof PingWebSocketFrame){
        context.channel().write(new PongWebSocketFrame(frame.content().retain()));
        return;
    }
    if(frame instanceof TextWebSocketFrame){
        handleTextMessage(context, ((TextWebSocketFrame) frame).text());
        return;
    }
    if(frame instanceof BinaryWebSocketFrame){
        handleBinaryMessage(context, frame);
        return;
    }
    throw new UnsupportedMessageTypeException(frame.getClass().getName());
}
项目:nedis    文件:RedisDuplexHandler.java   
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
        throws Exception {
    if (msg instanceof RedisRequest) {
        writeNormal(ctx, (RedisRequest) msg, promise);
    } else if (msg instanceof TxnRedisRequest) {
        writeTxn(ctx, (TxnRedisRequest) msg, promise);
    } else {
        throw new UnsupportedMessageTypeException(msg, RedisRequest.class,
                TxnRedisRequest.class);
    }
    scheduleTimeoutTask(ctx);
}