Search in sources :

Example 1 with MessagePacket

use of io.dingodb.net.netty.packet.impl.MessagePacket in project dingo by dingodb.

the class NetServiceLocalConnection method send.

@Override
public <S extends Packet<Message>> void send(S packet) {
    ChannelId channelId = packet.header().channelId();
    if (channelId == null) {
        throw new UnsupportedOperationException("Send message must have sub channel.");
    }
    MessagePacket sendPacket = MessagePacket.builder().mode(packet.header().mode()).type(packet.header().type()).channelId(packet.header().targetChannelId()).targetChannelId(packet.header().channelId()).content(packet.content()).msgNo(packet.header().msgNo()).build();
    MessageDispatcher.instance().dispatch(this, sendPacket);
}
Also used : MessagePacket(io.dingodb.net.netty.packet.impl.MessagePacket) SimpleChannelId(io.dingodb.net.netty.channel.impl.SimpleChannelId) ChannelId(io.dingodb.net.netty.channel.ChannelId)

Example 2 with MessagePacket

use of io.dingodb.net.netty.packet.impl.MessagePacket in project dingo by dingodb.

the class NetServiceConnectionSubChannel method send.

@Override
public void send(Message sendMsg) {
    MessagePacket packet = MessagePacket.builder().msgNo(nextSeq()).mode(PacketMode.USER_DEFINE).type(PacketType.USER_DEFINE).channelId(channelId).targetChannelId(targetChannelId).content(sendMsg).build();
    send(packet);
}
Also used : MessagePacket(io.dingodb.net.netty.packet.impl.MessagePacket)

Example 3 with MessagePacket

use of io.dingodb.net.netty.packet.impl.MessagePacket in project dingo by dingodb.

the class MessageDecoder method decode.

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
    if (!ctx.channel().isOpen()) {
        if (in.readableBytes() > 0) {
            log.info("Channel is closed, discarding remaining {} byte(s) in buffer.", in.readableBytes());
        }
        in.skipBytes(in.readableBytes());
        return;
    }
    ByteBuf messageBuf = readMessageBuf(in);
    if (messageBuf == null) {
        return;
    }
    Header header = readHeader(messageBuf);
    Message message = readMessage(messageBuf);
    out.add(new MessagePacket(header, message));
    messageBuf.release();
}
Also used : MessagePacket(io.dingodb.net.netty.packet.impl.MessagePacket) Header(io.dingodb.net.netty.packet.Header) Message(io.dingodb.net.Message) SimpleMessage(io.dingodb.net.SimpleMessage) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

MessagePacket (io.dingodb.net.netty.packet.impl.MessagePacket)3 Message (io.dingodb.net.Message)1 SimpleMessage (io.dingodb.net.SimpleMessage)1 ChannelId (io.dingodb.net.netty.channel.ChannelId)1 SimpleChannelId (io.dingodb.net.netty.channel.impl.SimpleChannelId)1 Header (io.dingodb.net.netty.packet.Header)1 ByteBuf (io.netty.buffer.ByteBuf)1