org.jdesktop.wonderland.client.cell
Class CellChannelConnection

java.lang.Object
  extended by org.jdesktop.wonderland.client.comms.BaseConnection
      extended by org.jdesktop.wonderland.client.cell.CellChannelConnection
All Implemented Interfaces:
CellCache.CellCacheListener, CellStatusChangeListener, ClientConnection

public class CellChannelConnection
extends BaseConnection
implements CellCache.CellCacheListener, CellStatusChangeListener

Handler for Cell Channels. All data to/from cells is handled via this class.

There is a potential ordering issues with cell channel messages. The CellHierarchyMessages to load a cell are sent to a single client, and thus are not sent over this channel. Therefore load messages can be out-of-order with respect to the cell messages. This handler maintains queues of delayed messages for each cell, to ensure these messages are delivered in the correct order.

Author:
Jonathan Kaplan

Nested Class Summary
protected static class CellChannelConnection.CellMessageDelivery
          Deliver messages to a particular cell.
protected static interface CellChannelConnection.MessageReceiver
          A message receiver
 
Nested classes/interfaces inherited from interface org.jdesktop.wonderland.client.comms.ClientConnection
ClientConnection.Status
 
Constructor Summary
CellChannelConnection()
           
 
Method Summary
 void cellLoaded(CellID cellID, Cell cell)
          When a new cell is loaded, add a status listener to set the channel when the cell becomes INACTIVE.
 void cellLoadFailed(CellID cellID, java.lang.String className, CellID parentCellID, java.lang.Throwable cause)
          Notification that a cell failed to load.
 void cellStatusChanged(Cell cell, CellStatus status)
          When a cell's status becomes inactive, set the channel object in the delivery correctly.
 void cellUnloaded(CellID cellID, Cell cell)
          Notification that a cell was unloaded.
protected  CellChannelConnection.CellMessageDelivery getCellMessageDelivery(CellID cellID)
          Get the cell message delivery for a particular cell.
 ConnectionType getConnectionType()
          Get the type of client
 void handleMessage(Message message)
          Handle a message from the server
 void send(CellMessage message)
          Send a cell message to a specific cell on the server
 void send(CellMessage message, ResponseListener listener)
          Send a cell message to a specific cell on the server with the given listener.
 ResponseMessage sendAndWait(CellMessage message)
          Send a cell messag to a specific cell on the server and wait for a response.
 
Methods inherited from class org.jdesktop.wonderland.client.comms.BaseConnection
addResponseListener, connect, connect, connected, disconnect, disconnected, getSession, getStatus, messageReceived, notifyResponseListener, send, send, sendAndWait, setStatus, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CellChannelConnection

public CellChannelConnection()
Method Detail

getConnectionType

public ConnectionType getConnectionType()
Get the type of client

Specified by:
getConnectionType in interface ClientConnection
Returns:
CellChannelConnectionType.CELL_CLIENT_TYPE

send

public void send(CellMessage message)
Send a cell message to a specific cell on the server

Parameters:
message - the cell message to send
See Also:
org.jdesktop.wonderland.client.comms.WonderlandSession#send(WonderlandClient, Message)

send

public void send(CellMessage message,
                 ResponseListener listener)
Send a cell message to a specific cell on the server with the given listener.

Parameters:
message - the message to send
listener - the response listener to notify when a response is received.
See Also:
org.jdesktop.wonderland.client.comms.WonderlandSession#send(WonderlandClient, Message, ResponseListener)

sendAndWait

public ResponseMessage sendAndWait(CellMessage message)
                            throws java.lang.InterruptedException
Send a cell messag to a specific cell on the server and wait for a response.

Parameters:
message - the message to send
Throws:
java.lang.InterruptedException - if there is a problem sending a message to the given cell
See Also:
org.jdesktop.wonderland.client.comms.WonderlandSession#sendAndWait(WonderlandClient, Message)

handleMessage

public void handleMessage(Message message)
Handle a message from the server

Specified by:
handleMessage in class BaseConnection
Parameters:
message - the message to handle

getCellMessageDelivery

protected CellChannelConnection.CellMessageDelivery getCellMessageDelivery(CellID cellID)
Get the cell message delivery for a particular cell. This method always returns an object. If there is no delivery object for the given cellID, a new one is created.

Parameters:
cellID - the cellID to get a deliver object for
Returns:
the message delivery object for the given cell

cellLoaded

public void cellLoaded(CellID cellID,
                       Cell cell)
When a new cell is loaded, add a status listener to set the channel when the cell becomes INACTIVE.

Specified by:
cellLoaded in interface CellCache.CellCacheListener
Parameters:
cellID - the id of the loaded cell
cell - the cell that was loaded

cellStatusChanged

public void cellStatusChanged(Cell cell,
                              CellStatus status)
When a cell's status becomes inactive, set the channel object in the delivery correctly. This method is guaranteed to be called after all cell component's status has been set, so it is safe to assume that any message listeners that are going to be set up will be set up.

Specified by:
cellStatusChanged in interface CellStatusChangeListener
Parameters:
cell - the cells whoes status has changed
status - the new status for the cell

cellLoadFailed

public void cellLoadFailed(CellID cellID,
                           java.lang.String className,
                           CellID parentCellID,
                           java.lang.Throwable cause)
Description copied from interface: CellCache.CellCacheListener
Notification that a cell failed to load.

Specified by:
cellLoadFailed in interface CellCache.CellCacheListener
Parameters:
cellID - the id of the cell that didn't load
className - the name of the cell that didn't load
parentCellID - the id of the cell's parent
cause - the reason the cell didn't load

cellUnloaded

public void cellUnloaded(CellID cellID,
                         Cell cell)
Description copied from interface: CellCache.CellCacheListener
Notification that a cell was unloaded. This will be called after the cell has been unloaded, but before its status has been changed.

Specified by:
cellUnloaded in interface CellCache.CellCacheListener
Parameters:
cellID - the id of the unloaded cell
cell - the cell that was unloaded


Open Wonderland - http://openwonderland.org