Search in sources :

Example 71 with ChannelBuffer

use of org.jboss.netty.buffer.ChannelBuffer in project pinpoint by naver.

the class ControlHandshakeResponsePacket method readBuffer.

public static ControlHandshakeResponsePacket readBuffer(short packetType, ChannelBuffer buffer) {
    assert packetType == PacketType.CONTROL_HANDSHAKE_RESPONSE;
    if (buffer.readableBytes() < 8) {
        buffer.resetReaderIndex();
        return null;
    }
    final int messageId = buffer.readInt();
    final ChannelBuffer payload = PayloadPacket.readPayload(buffer);
    if (payload == null) {
        return null;
    }
    final ControlHandshakeResponsePacket helloPacket = new ControlHandshakeResponsePacket(payload.array());
    helloPacket.setRequestId(messageId);
    return helloPacket;
}
Also used : ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 72 with ChannelBuffer

use of org.jboss.netty.buffer.ChannelBuffer in project pinpoint by naver.

the class PayloadPacket method appendPayload.

public static ChannelBuffer appendPayload(final ChannelBuffer header, final byte[] payload) {
    if (payload == null) {
        // this is also payload header
        header.writeInt(-1);
        return header;
    } else {
        header.writeInt(payload.length);
        ChannelBuffer payloadWrap = ChannelBuffers.wrappedBuffer(payload);
        return ChannelBuffers.wrappedBuffer(true, header, payloadWrap);
    }
}
Also used : ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 73 with ChannelBuffer

use of org.jboss.netty.buffer.ChannelBuffer in project pinpoint by naver.

the class PingPacket method toBuffer.

@Override
public ChannelBuffer toBuffer() {
    if (pingId == -1) {
        return ChannelBuffers.wrappedBuffer(PING_BYTE);
    } else {
        // 2 + 4 + 1 + 1
        ChannelBuffer buffer = ChannelBuffers.buffer(8);
        buffer.writeShort(PacketType.CONTROL_PING);
        buffer.writeInt(pingId);
        buffer.writeByte(stateVersion);
        buffer.writeByte(stateCode);
        return buffer;
    }
}
Also used : ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 74 with ChannelBuffer

use of org.jboss.netty.buffer.ChannelBuffer in project pinpoint by naver.

the class RequestPacket method readBuffer.

public static RequestPacket readBuffer(short packetType, ChannelBuffer buffer) {
    assert packetType == PacketType.APPLICATION_REQUEST;
    if (buffer.readableBytes() < 8) {
        buffer.resetReaderIndex();
        return null;
    }
    final int messageId = buffer.readInt();
    final ChannelBuffer payload = PayloadPacket.readPayload(buffer);
    if (payload == null) {
        return null;
    }
    final RequestPacket requestPacket = new RequestPacket(payload.array());
    requestPacket.setRequestId(messageId);
    return requestPacket;
}
Also used : ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 75 with ChannelBuffer

use of org.jboss.netty.buffer.ChannelBuffer in project pinpoint by naver.

the class ResponsePacket method toBuffer.

@Override
public ChannelBuffer toBuffer() {
    ChannelBuffer header = ChannelBuffers.buffer(2 + 4 + 4);
    header.writeShort(PacketType.APPLICATION_RESPONSE);
    header.writeInt(requestId);
    return PayloadPacket.appendPayload(header, payload);
}
Also used : ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Aggregations

ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)494 DefaultHttpResponse (org.jboss.netty.handler.codec.http.DefaultHttpResponse)70 Test (org.junit.Test)67 DeviceSession (org.traccar.DeviceSession)64 Position (org.traccar.model.Position)62 HttpResponse (org.jboss.netty.handler.codec.http.HttpResponse)61 Test (org.testng.annotations.Test)49 HttpChunk (org.jboss.netty.handler.codec.http.HttpChunk)48 DefaultHttpChunk (org.jboss.netty.handler.codec.http.DefaultHttpChunk)44 HttpChunkTrailer (org.jboss.netty.handler.codec.http.HttpChunkTrailer)37 DefaultHttpChunkTrailer (org.jboss.netty.handler.codec.http.DefaultHttpChunkTrailer)34 ChannelFuture (org.jboss.netty.channel.ChannelFuture)28 Checkpoint (com.linkedin.databus.core.Checkpoint)27 ByteBuffer (java.nio.ByteBuffer)27 RecoverablePduException (com.cloudhopper.smpp.type.RecoverablePduException)26 UnrecoverablePduException (com.cloudhopper.smpp.type.UnrecoverablePduException)26 DateBuilder (org.traccar.helper.DateBuilder)26 BootstrapDatabaseTooOldException (com.linkedin.databus2.core.container.request.BootstrapDatabaseTooOldException)25 IOException (java.io.IOException)23 ArrayList (java.util.ArrayList)23