Package org.activeio

Examples of org.activeio.PacketData


    private void serviceRequest(Packet packet) {
        try {
            if( requestListener ==null )
                throw new IOException("The RequestListener has not been set.");

            PacketData data = new PacketData(packet);
            short requestId = data.readShort();           
            Packet reponse = requestListener.onRequest(packet);

            // Send the response...
            Packet header = createHeaderPacket(RESPONSE, requestId);       
            Packet rc = AppendedPacket.join(header, packet);       
View Full Code Here


    private void serviceReponse(Packet packet) {
       
        try {
           
            PacketData data = new PacketData(packet);
            short requestId = data.readShort();
           
            Slot responseSlot = (Slot) requestMap.get(new Short(requestId));
            responseSlot.put(packet);
           
        } catch (IOException e) {
View Full Code Here

        }       
    }

    private Packet createHeaderPacket(byte type, short requestId) throws IOException {
        ByteArrayPacket header = new ByteArrayPacket(new byte[]{3});
        PacketData data = new PacketData(header);
        data.writeByte(type);
        data.writeShort(requestId);
        header.flip();
        return header;
    }
View Full Code Here

    public int getLogFileOffset() {
        return logFileOffset;
    }
   
    public void writeToPacket(Packet packet) throws IOException {
        PacketData data = new PacketData(packet);
        data.writeInt(logFileId);
        data.writeInt(logFileOffset);
    }
View Full Code Here

        data.writeInt(logFileId);
        data.writeInt(logFileOffset);
    }   

    static public Location readFromPacket(Packet packet) throws IOException {
        PacketData data = new PacketData(packet);
        return new Location(data.readInt(), data.readInt());
    }
View Full Code Here

        while (true) {

            if (!headerLoaded) {
                headerLoaded = packet.remaining() >= HEADER_LENGTH;
                if( headerLoaded ) {
                    PacketData data = new PacketData(packet);
                    upPacketLength = data.readInt();
                    if( upPacketLength < 0 ) {
                        throw new IOException("Up packet lenth was invalid: "+upPacketLength);
                    }
                    packet = packet.slice();
                }
View Full Code Here

        while (true) {

            if (!headerLoaded) {
                headerLoaded = packet.remaining() >= HEADER_LENGTH;
                if( headerLoaded ) {
                    PacketData data = new PacketData(packet.duplicate());
                    data.readByte();
                    upPacketLength = data.readInt();
                    if( upPacketLength < 0 ) {
                        throw new IOException("Up packet lenth was invalid: "+upPacketLength);
                    }
                    upPacketLength+=HEADER_LENGTH;
                }
View Full Code Here

            packet.setMemoryUsage(count);
           
            // Now write the headers to the packet.
           
            rc.position(startPosition);
            PacketData pd = new PacketData(rc);
            pd.writeByte(packet.getPacketType());
            pd.writeInt(count);
            rc.rewind();
            return rc;
        }
        return null;
    }
View Full Code Here

        while (true) {

            if (!headerLoaded) {
                headerLoaded = packet.remaining() >= HEADER_LENGTH;
                if( headerLoaded ) {
                    PacketData data = new PacketData(packet.duplicate());
                    data.readByte();
                    upPacketLength = data.readInt();
                    if( upPacketLength < 0 ) {
                        throw new IOException("Up packet lenth was invalid: "+upPacketLength);
                    }
                    upPacketLength+=HEADER_LENGTH;
                }
View Full Code Here

            packet.setMemoryUsage(count);
           
            // Now write the headers to the packet.
           
            rc.position(startPosition);
            PacketData pd = new PacketData(rc);
            pd.writeByte(packet.getPacketType());
            pd.writeInt(count);
            rc.rewind();
            return rc;
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.activeio.PacketData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.