use of io.mycat.proxy.buffer.ProxyBufferImpl in project Mycat2 by MyCATApache.
the class MySQLClientSession method writeCurrentProxyPacket.
/**
* newCurrentProxyPacket的配套方法,把该方法构造的报文写入通道
*/
public void writeCurrentProxyPacket(MySQLPacket ogrin, int packetId) throws IOException {
ProxyBufferImpl mySQLPacket1 = (ProxyBufferImpl) ogrin;
ByteBuffer buffer = mySQLPacket1.currentByteBuffer();
int packetEndPos = buffer.position();
int payloadLen = buffer.position() - 4;
if (payloadLen < MySQLPacketSplitter.MAX_PACKET_SIZE) {
ogrin.putFixInt(0, 3, payloadLen);
ogrin.putByte(3, (byte) packetId);
ProxyBuffer packet1 = (ProxyBuffer) ogrin;
packet1.channelWriteStartIndex(0);
packet1.channelWriteEndIndex(packetEndPos);
writeToChannel();
} else {
throw new MycatException("unsupport max packet {}", MySQLPacketSplitter.MAX_PACKET_SIZE);
}
}
Aggregations