Class SocketObserverAdapter
- All Implemented Interfaces:
SocketObserver
- Author:
- Christoffer Lerno
-
Field Summary
Fields inherited from interface naga.SocketObserver
NULL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconnectionBroken(NIOSocket nioSocket, Exception exception) Called by the NIOService on the NIO thread when a connection is disconnected.voidconnectionOpened(NIOSocket nioSocket) Called by the NIOService on the NIO thread when a connection completes on a socket.voidpacketReceived(NIOSocket socket, byte[] packet) Called by the NIOService on the NIO thread when a packet is finished reading.voidpacketSent(NIOSocket socket, Object tag) Called by the NIOService on the NIO thread when a packet has finished writing.
-
Constructor Details
-
SocketObserverAdapter
public SocketObserverAdapter()
-
-
Method Details
-
connectionBroken
Description copied from interface:SocketObserverCalled by the NIOService on the NIO thread when a connection is disconnected.This may be sent even if a
connectionOpened(NIOSocket)wasn't ever called, since the connect itself may fail.Note: Since this is a direct callback on the NIO thread, this method will suspend IO on all other connections until the method returns. It is therefore strongly recommended that the implementation of this method returns as quickly as possible to avoid blocking IO.
- Specified by:
connectionBrokenin interfaceSocketObserver- Parameters:
nioSocket- the socket that was disconnected.exception- the exception that caused the connection to break, may be null.
-
packetReceived
Description copied from interface:SocketObserverCalled by the NIOService on the NIO thread when a packet is finished reading. The byte array contains the packet as parsed by the current PacketReader.Note: Since this is a direct callback on the NIO thread, this method will suspend IO on all other connections until the method returns. It is therefore strongly recommended that the implementation of this method returns as quickly as possible to avoid blocking IO.
- Specified by:
packetReceivedin interfaceSocketObserver- Parameters:
socket- the socket we received a packet on.packet- the packet we received.
-
connectionOpened
Description copied from interface:SocketObserverCalled by the NIOService on the NIO thread when a connection completes on a socket.Note: Since this is a direct callback on the NIO thread, this method will suspend IO on all other connections until the method returns. It is therefore strongly recommended that the implementation of this method returns as quickly as possible to avoid blocking IO.
- Specified by:
connectionOpenedin interfaceSocketObserver- Parameters:
nioSocket- the socket that completed its connect.
-
packetSent
Description copied from interface:SocketObserverCalled by the NIOService on the NIO thread when a packet has finished writing.Note: Since this is a direct callback on the NIO thread, this method will suspend IO on all other connections until the method returns. It is therefore strongly recommended that the implementation of this method returns as quickly as possible to avoid blocking IO.
- Specified by:
packetSentin interfaceSocketObserver- Parameters:
socket- the socket we sent the packet on.tag- the (optional) tag associated with the packet.
-