com.hazelcast.nio.tcp

## Class PacketEncoder

- java.lang.Object
- - com.hazelcast.nio.tcp.PacketEncoder

- All Implemented Interfaces:
    com.hazelcast.internal.networking.ChannelOutboundHandler<Packet>

      public class PacketEncoder
      extends Object
      implements com.hazelcast.internal.networking.ChannelOutboundHandler<Packet>

  A `ChannelOutboundHandler` that for member to member communication. It writes `Packet` instances to the `ByteBuffer`. It makes use of a flyweight to allow the sharing of a packet-instance over multiple connections. The flyweight contains the actual 'position' state of what has been written.
  See Also:
    `PacketDecoder`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PacketEncoder()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `onWrite(Packet packet, ByteBuffer dst)` A callback to indicate that the Frame should be written to the destination ByteBuffer.

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

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

- - ### Constructor Detail

    - #### PacketEncoder

          public PacketEncoder()

  - ### Method Detail

    - #### onWrite

          public boolean onWrite(Packet packet,
                                 ByteBuffer dst)

      Description copied from interface: `com.hazelcast.internal.networking.ChannelOutboundHandler`
      A callback to indicate that the Frame should be written to the destination ByteBuffer. It could be that a Frame is too big to fit into the ByteBuffer in 1 go; in that case this call will be made for the same Frame multiple times until write returns true.
      Specified by:
        `onWrite` in interface `com.hazelcast.internal.networking.ChannelOutboundHandler<Packet>`
      Parameters:
        `packet` - the Frame to write
        `dst` - the destination ByteBuffer
      Returns:
        true if the Frame is completely written

Copyright © 2018. All rights reserved.