本文整理汇总了Java中org.jboss.netty.buffer.ChannelBuffers.directBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelBuffers.directBuffer方法的具体用法?Java ChannelBuffers.directBuffer怎么用?Java ChannelBuffers.directBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.netty.buffer.ChannelBuffers
的用法示例。
在下文中一共展示了ChannelBuffers.directBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseIdentification
import org.jboss.netty.buffer.ChannelBuffers; //导入方法依赖的package包/类
private DeviceSession parseIdentification(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
int length = buf.readUnsignedShort();
String imei = buf.toString(buf.readerIndex(), length, StandardCharsets.US_ASCII);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (channel != null) {
ChannelBuffer response = ChannelBuffers.directBuffer(1);
if (deviceSession != null) {
response.writeByte(1);
} else {
response.writeByte(0);
}
channel.write(response);
}
return deviceSession;
}
示例2: sendReply
import org.jboss.netty.buffer.ChannelBuffers; //导入方法依赖的package包/类
private void sendReply(Channel channel, SocketAddress remoteAddress, long deviceId, byte packetNumber) {
ChannelBuffer reply = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 28);
reply.writeByte('M');
reply.writeByte('C');
reply.writeByte('G');
reply.writeByte('P');
reply.writeByte(MSG_SERVER_ACKNOWLEDGE);
reply.writeInt((int) deviceId);
reply.writeByte(commandCount++);
reply.writeInt(0); // authentication code
reply.writeByte(0);
reply.writeByte(packetNumber);
reply.writeZero(11);
byte checksum = 0;
for (int i = 4; i < 27; i++) {
checksum += reply.getByte(i);
}
reply.writeByte(checksum);
if (channel != null) {
channel.write(reply, remoteAddress);
}
}
示例3: sendResponse
import org.jboss.netty.buffer.ChannelBuffers; //导入方法依赖的package包/类
private void sendResponse(
Channel channel, SocketAddress remoteAddress,
int version, ChannelBuffer id, short type, ChannelBuffer content) {
if (channel != null) {
int length = 2 + 2 + 1 + id.readableBytes() + 2 + 2 + 2;
if (content != null) {
length += content.readableBytes();
}
ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, length);
response.writeByte('@'); response.writeByte('@');
response.writeShort(length);
response.writeByte(version);
response.writeBytes(id);
response.writeShort(ChannelBuffers.swapShort(type));
if (content != null) {
response.writeBytes(content);
}
response.writeShort(
Checksum.crc16(Checksum.CRC16_X25, response.toByteBuffer(0, response.writerIndex())));
response.writeByte(0x0D); response.writeByte(0x0A);
channel.write(response, remoteAddress);
}
}
示例4: sendAcknowledgment
import org.jboss.netty.buffer.ChannelBuffers; //导入方法依赖的package包/类
private void sendAcknowledgment(Channel channel, int sequenceNumber) {
ChannelBuffer data = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 4);
data.writeShort(sequenceNumber);
data.writeShort(0); // OK
ChannelBuffer header = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 20);
header.writeByte(1); header.writeByte(0);
header.writeShort(senderSequenceNumber++);
header.writeShort(MSG_ACKNOWLEDGEMENT);
header.writeShort(header.capacity() + data.capacity());
header.writeShort(0);
header.writeShort(Checksum.crc16(Checksum.CRC16_CCITT_FALSE, data.toByteBuffer()));
header.writeInt(0);
header.writeInt((int) (System.currentTimeMillis() / 1000) + LEAP_SECONDS_DELTA);
if (channel != null) {
channel.write(ChannelBuffers.copiedBuffer(header, data));
}
}
示例5: sendReply
import org.jboss.netty.buffer.ChannelBuffers; //导入方法依赖的package包/类
private void sendReply(Channel channel, int checksum) {
ChannelBuffer reply = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 3);
reply.writeByte(0x02);
reply.writeShort((short) checksum);
if (channel != null) {
channel.write(reply);
}
}
示例6: requestArchive
import org.jboss.netty.buffer.ChannelBuffers; //导入方法依赖的package包/类
private void requestArchive(Channel channel) {
if (lastIndex == 0) {
lastIndex = newIndex;
} else if (newIndex > lastIndex) {
ChannelBuffer request = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 12);
request.writeShort(MSG_LOG_SYNC);
request.writeShort(4);
request.writeInt((int) lastIndex);
request.writeInt(0);
channel.write(request);
}
}
示例7: sendSimpleMessage
import org.jboss.netty.buffer.ChannelBuffers; //导入方法依赖的package包/类
private void sendSimpleMessage(Channel channel, short type) {
ChannelBuffer request = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 8);
request.writeShort(type);
request.writeShort(0);
request.writeInt(Checksum.crc32(request.toByteBuffer(0, 4)));
channel.write(request);
}
示例8: requestArchive
import org.jboss.netty.buffer.ChannelBuffers; //导入方法依赖的package包/类
private void requestArchive(Channel channel) {
if (lastIndex == 0) {
lastIndex = newIndex;
} else if (newIndex > lastIndex) {
ChannelBuffer request = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 14);
request.writeShort(MSG_REQUEST_LOG_RECORDS);
request.writeShort(6);
request.writeInt((int) lastIndex);
request.writeShort(512);
request.writeInt(Checksum.crc32(request.toByteBuffer(0, 10)));
channel.write(request);
}
}
示例9: sendResponse
import org.jboss.netty.buffer.ChannelBuffers; //导入方法依赖的package包/类
private void sendResponse(Channel channel, SocketAddress remoteAddress, int type, int index, int result) {
if (channel != null) {
ChannelBuffer response = ChannelBuffers.directBuffer(10);
response.writeByte(SERVICE_RESPONSE);
response.writeByte(MSG_ACK);
response.writeShort(index);
response.writeByte(type);
response.writeByte(result);
response.writeByte(0);
response.writeMedium(0);
channel.write(response, remoteAddress);
}
}
示例10: sendResponse
import org.jboss.netty.buffer.ChannelBuffers; //导入方法依赖的package包/类
private static void sendResponse(Channel channel, SocketAddress remoteAddress, long rawId, int index) {
if (channel != null) {
ChannelBuffer response = ChannelBuffers.directBuffer(12);
response.writeShort(0xfe02);
response.writeLong(rawId);
response.writeShort(index);
channel.write(response, remoteAddress);
}
}
示例11: sendResponse
import org.jboss.netty.buffer.ChannelBuffers; //导入方法依赖的package包/类
private void sendResponse(Channel channel, int type) {
if (channel != null) {
ChannelBuffer response = ChannelBuffers.directBuffer(5);
response.writeByte('$');
response.writeByte(type);
response.writeByte('#');
response.writeByte('\r'); response.writeByte('\n');
channel.write(response);
}
}
示例12: sendResponse
import org.jboss.netty.buffer.ChannelBuffers; //导入方法依赖的package包/类
private void sendResponse(Channel channel) {
if (channel != null) {
ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 2 * BLOCK_LENGTH);
response.writeByte(At2000ProtocolDecoder.MSG_ACKNOWLEDGEMENT);
response.writeMedium(ChannelBuffers.swapMedium(1));
response.writeByte(0x00); // success
response.writerIndex(2 * BLOCK_LENGTH);
channel.write(response);
}
}
示例13: sendRequest
import org.jboss.netty.buffer.ChannelBuffers; //导入方法依赖的package包/类
private static void sendRequest(Channel channel) {
if (channel != null) {
ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, BLOCK_LENGTH);
response.writeByte(MSG_TRACK_REQUEST);
response.writeMedium(ChannelBuffers.swapMedium(0));
response.writerIndex(BLOCK_LENGTH);
channel.write(response);
}
}
示例14: sendReply
import org.jboss.netty.buffer.ChannelBuffers; //导入方法依赖的package包/类
private void sendReply(Channel channel, ChannelBuffer data) {
ChannelBuffer header = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 16);
header.writeBytes(ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, prefix, StandardCharsets.US_ASCII));
header.writeInt((int) deviceUniqueId);
header.writeInt((int) serverId);
header.writeShort(data.readableBytes());
header.writeByte(checksum(data));
header.writeByte(checksum(header));
if (channel != null) {
channel.write(ChannelBuffers.copiedBuffer(header, data));
}
}
示例15: sendResponse
import org.jboss.netty.buffer.ChannelBuffers; //导入方法依赖的package包/类
private static void sendResponse(Channel channel, ChannelBuffer buf) {
if (channel != null) {
ChannelBuffer response = ChannelBuffers.directBuffer(4);
response.writeByte('*');
response.writeShort(buf.getUnsignedShort(buf.writerIndex() - 2));
response.writeByte(buf.getUnsignedByte(buf.writerIndex() - 3));
channel.write(response);
}
}