SSLPacketHandler (Naga API)
Date: 2016-06-28

naga

## Class SSLPacketHandler

- java.lang.Object
- - naga.SSLPacketHandler

- All Implemented Interfaces:
    PacketReader, PacketWriter

      public class SSLPacketHandler
      extends java.lang.Object
      implements PacketReader, PacketWriter

  Undocumented Class
  Author:
    Christoffer Lerno

- - ### Field Summary

    - ### Fields inherited from interface naga.PacketReader

      `SKIP_PACKET`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SSLPacketHandler(javax.net.ssl.SSLEngine engine, NIOSocket socket, naga.SSLSocketChannelResponder responder)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `closeEngine()`
    `PacketReader` | `getReader()`
    `javax.net.ssl.SSLEngine` | `getSSLEngine()`
    `PacketWriter` | `getWriter()`
    `boolean` | `isEncrypted()`
    `byte[]` | `nextPacket(java.nio.ByteBuffer byteBuffer)` Create a new packet using the ByteBuffer given.
    `void` | `setReader(PacketReader reader)`
    `void` | `setWriter(PacketWriter writer)`
    `java.nio.ByteBuffer[]` | `write(java.nio.ByteBuffer[] byteBuffers)` Convert the incoming bytes to the bytes to be serialized.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SSLPacketHandler

          public SSLPacketHandler(javax.net.ssl.SSLEngine engine,
                          NIOSocket socket,
                          naga.SSLSocketChannelResponder responder)

  - ### Method Detail

    - #### getReader

          public PacketReader getReader()

    - #### setReader

          public void setReader(PacketReader reader)

    - #### getWriter

          public PacketWriter getWriter()

    - #### setWriter

          public void setWriter(PacketWriter writer)

    - #### nextPacket

          public byte[] nextPacket(java.nio.ByteBuffer byteBuffer)
                            throws ProtocolViolationException

      Description copied from interface: `PacketReader`
      Create a new packet using the ByteBuffer given.

      If there isn't sufficient data to construct a packet, return null.
      Specified by:
        `nextPacket` in interface `PacketReader`
      Parameters:
        `byteBuffer` - the byte buffer to use.
      Returns:
        the new packet created, or null if no packet could be created. The method will continously be called until nextPacket returns null.
      Throws:
        `ProtocolViolationException` - is there was an error constructing the packet.

    - #### write

          public java.nio.ByteBuffer[] write(java.nio.ByteBuffer[] byteBuffers)

      Description copied from interface: `PacketWriter`
      Convert the incoming bytes to the bytes to be serialized.
      Specified by:
        `write` in interface `PacketWriter`
      Parameters:
        `byteBuffers` - an array of ByteBuffers containing data the bytes to be written.
      Returns:
        the resulting array of ByteBuffers.

    - #### getSSLEngine

          public javax.net.ssl.SSLEngine getSSLEngine()

    - #### closeEngine

          public void closeEngine()

    - #### isEncrypted

          public boolean isEncrypted()