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);
}
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);
}
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();
}
Aggregations