com.esotericsoftware.kryonet
Class Listener

java.lang.Object
  extended by com.esotericsoftware.kryonet.Listener
Direct Known Subclasses:
Listener.QueuedListener, Listener.ReflectionListener

public class Listener
extends java.lang.Object

Used to be notified about connection events.


Nested Class Summary
static class Listener.LagListener
          Delays the notification of the wrapped listener to simulate lag on incoming objects.
static class Listener.QueuedListener
          Wraps a listener and queues notifications as runnables.
static class Listener.ReflectionListener
          Uses reflection to called "received(Connection, XXX)" on the listener, where XXX is the received object type.
static class Listener.ThreadedListener
          Wraps a listener and processes notification events on a separate thread.
 
Constructor Summary
Listener()
           
 
Method Summary
 void connected(Connection connection)
          Called when the remote end has been connected.
 void disconnected(Connection connection)
          Called when the remote end is no longer connected.
 void received(Connection connection, java.lang.Object object)
          Called when an object has been received from the remote end of the connection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Listener

public Listener()
Method Detail

connected

public void connected(Connection connection)
Called when the remote end has been connected. This will be invoked before any objects are received by received(Connection, Object). This will be invoked on the same thread as Client.update(int) and Server.update(int). This method should not block for long periods as other network activity will not be processed until it returns.


disconnected

public void disconnected(Connection connection)
Called when the remote end is no longer connected. There is no guarantee as to what thread will invoke this method.


received

public void received(Connection connection,
                     java.lang.Object object)
Called when an object has been received from the remote end of the connection. This will be invoked on the same thread as Client.update(int) and Server.update(int). This method should not block for long periods as other network activity will not be processed until it returns.