hypercast
Interface I_AdapterCallback

All Known Implementing Classes:
DT_Node, DT_Node_BuddyList, DT_Node_Multicast, DT_Server, GNP_Landmark, HC_Node, OL_Socket, SecurityProcessor, SPT_Node

public interface I_AdapterCallback

This interface is implemented by a UDP/TCP unicast adapter or a UDP multicast adapter. * The method is called whenever there is a message arriving the adapter.


Method Summary
 void messageArrivedFromAdapter(hypercast.I_Message msg)
          Handles the incoming message (unicast, server, or multicast).
 hypercast.I_Message restoreMessage(byte[] receiveBuffer, int[] validBytesStart, int validBytesEnd)
          Creates a message from bytes in a buffer.
 void timerExpired(java.lang.Object timerID)
          Handles the arrival of a timer
 

Method Detail

messageArrivedFromAdapter

public void messageArrivedFromAdapter(hypercast.I_Message msg)
Handles the incoming message (unicast, server, or multicast).

Throws:
java.lang.IllegalArgumentException - if I_Message is of incorrect type. (An incorrect type being one different than that returned by restoreMessage(). )

timerExpired

public void timerExpired(java.lang.Object timerID)
Handles the arrival of a timer

Throws:
java.lang.IllegalArgumentException - if timerID is unexpected.

restoreMessage

public hypercast.I_Message restoreMessage(byte[] receiveBuffer,
                                          int[] validBytesStart,
                                          int validBytesEnd)
Creates a message from bytes in a buffer. validBytesStart[0] is the start of the segment of unread bytes in receiveBuffer. validBytesEnd is one beyond the end of the segment of unread bytes in receiveBuffer. If a message is contained in the buffer, the function increases validBytesStart[0] to point to the new beginning of unread bytes in the buffer. If no message is contained in the buffer, null is returned. If the buffer contains corrupt or bad messages, an IllegalArgumentException should be thrown.

Parameters:
receiveBuffer - the byte array buffer of a incoming stream
validBytesStart - the start index to create a message from
validBytesEnd - the total length of bytes in this buffer
Returns:
null if buffer does not contain a complete message.
Throws:
java.lang.IllegalArgumentException