Package org.ImmortalSockets.packet

Examples of org.ImmortalSockets.packet.Packet


  protected void writeChannel(SocketChannel channel) {
    // If there is a packet to send.
    if (!packetQueue.isEmpty()) {

      // Get the packet from the queue.
      Packet packetToSend;
      packetToSend = packetQueue.poll();

      try {
        // Write the packet content to the channel.
        channel.write(packetToSend.getByteBuffer());
      } catch (IOException e) {
        // If there is an IO Exception we assumed the connection died
        // and we try to reconnect.
        reconnect();
      }
View Full Code Here


     * packets and adding them to the queue of the packets that have to be
     * send.
     */
    public void run() {
      int bytesRead;
      Packet packetToSend;
      try {
        while ((bytesRead = outputPipedInput.read(buffer)) != -1) {
          // Create the packet.
          packetToSend = new DataPacket(buffer, 0, bytesRead);

View Full Code Here

          /*
           * We format the data receive into a packet and process it
           * depending on its type.
           */
          Packet packet;
          while (readBuffer.hasRemaining()
              && (packet = Packet.process(readBuffer)) != null) {
            if (packet instanceof DataPacket)
              // If it's a data packet we forward the associated
              // bytes to the software.
View Full Code Here

TOP

Related Classes of org.ImmortalSockets.packet.Packet

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.