org.jdesktop.wonderland.server.cell
Class ChannelComponentMO

java.lang.Object
  extended by org.jdesktop.wonderland.server.cell.CellComponentMO
      extended by org.jdesktop.wonderland.server.cell.ChannelComponentMO
All Implemented Interfaces:
com.sun.sgs.app.ManagedObject, java.io.Serializable

public class ChannelComponentMO
extends CellComponentMO

Channel component is the basic component cells use to manage communication. The channel contained in the channel component contains subscriptions for all views that have this cell in their cache. It can be used to send messages to all clients with a given cell in view.

The channel component appears as a single Channel for each cell in the system, but in reality, this may be optimized so that multiple cells with the same set of viewers share a channel. This channel sharing is good for cells without a lot of communication, but cells that send lots of messages should force a local channel. This can be done by calling the addLocalChannelRequest() method. As long as there are any outstanding local channel requests, the cell will force the use of a local channel.

Author:
Paul Byrne , Jonathan Kaplan
See Also:
Serialized Form

Nested Class Summary
static interface ChannelComponentMO.ComponentMessageReceiver
          A listener to notify when messages of a certain class are recevied by this cell.
 
Field Summary
 
Fields inherited from class org.jdesktop.wonderland.server.cell.CellComponentMO
cellID, cellRef
 
Constructor Summary
ChannelComponentMO(CellMO cell)
          Create a new ChanneComponentMO.
 
Method Summary
 void addLocalChannelRequest(java.lang.String request)
          Add a request for a local channel.
 void addMessageReceiver(java.lang.Class<? extends CellMessage> msgClass, ChannelComponentMO.ComponentMessageReceiver receiver)
          Register a receiver for a specific message class.
 void addUserToCellChannel(WonderlandClientID clientID)
          Add user to the cells channel, if there is no channel simply return
protected  void closeChannel()
          Close the channel for this component.
 java.util.Iterator<WonderlandClientID> getChannelMembers()
          Get a list of all members of the given channel
protected  java.lang.String getClientClass()
          If this component has a client side component then return the fully qualified name of the client class.
 void messageReceived(WonderlandClientSender sender, WonderlandClientID clientID, CellMessage message)
          Dispatch messages to any receivers registered for the particular message class
protected  void openChannel()
          Open the channel for this component.
 void removeLocalChannelRequest(java.lang.String request)
          Remove a request for a local channel.
 void removeMessageReceiver(java.lang.Class<? extends CellMessage> msgClass)
           
 void removeUserFromCellChannel(WonderlandClientID clientID)
          Remove user from the cells channel
 void sendAll(WonderlandClientID senderID, CellMessage message)
          Send message to all clients on this channel
protected  void setLive(boolean live)
           
 
Methods inherited from class org.jdesktop.wonderland.server.cell.CellComponentMO
getClientState, getServerState, isLive, setServerState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChannelComponentMO

public ChannelComponentMO(CellMO cell)
Create a new ChanneComponentMO.

Parameters:
cell - the cell this component is attached to
Method Detail

openChannel

protected void openChannel()
Open the channel for this component.


closeChannel

protected void closeChannel()
Close the channel for this component.


setLive

protected void setLive(boolean live)
Overrides:
setLive in class CellComponentMO

sendAll

public void sendAll(WonderlandClientID senderID,
                    CellMessage message)
Send message to all clients on this channel

Parameters:
senderID - the id of the sender session, or null if this message being sent by the server
message -

addLocalChannelRequest

public void addLocalChannelRequest(java.lang.String request)
Add a request for a local channel. Request names are, by convention, the class name of the component making the request. If a cell wants to always force a local channel, it can use its own classname in the request. As long as there are any requests outstanding, a local channel will be created. XXX NOT IMPLEMENTED XXX

Parameters:
request - the request to add, by convention the classname of the requesting class

removeLocalChannelRequest

public void removeLocalChannelRequest(java.lang.String request)
Remove a request for a local channel.

Parameters:
request - the request to remove

addUserToCellChannel

public void addUserToCellChannel(WonderlandClientID clientID)
Add user to the cells channel, if there is no channel simply return

Parameters:
userID -

removeUserFromCellChannel

public void removeUserFromCellChannel(WonderlandClientID clientID)
Remove user from the cells channel

Parameters:
userID -

getChannelMembers

public java.util.Iterator<WonderlandClientID> getChannelMembers()
Get a list of all members of the given channel

Returns:
an iterator of channel members

addMessageReceiver

public void addMessageReceiver(java.lang.Class<? extends CellMessage> msgClass,
                               ChannelComponentMO.ComponentMessageReceiver receiver)
Register a receiver for a specific message class. Only a single receiver is allowed for each message class, calling this method to add a duplicate receiver will cause an IllegalStateException to be thrown.

Parameters:
msgClass -
receiver -

removeMessageReceiver

public void removeMessageReceiver(java.lang.Class<? extends CellMessage> msgClass)

getClientClass

protected java.lang.String getClientClass()
Description copied from class: CellComponentMO
If this component has a client side component then return the fully qualified name of the client class. If there is no client portion to this component, return null.

Specified by:
getClientClass in class CellComponentMO
Returns:

messageReceived

public void messageReceived(WonderlandClientSender sender,
                            WonderlandClientID clientID,
                            CellMessage message)
Dispatch messages to any receivers registered for the particular message class

Parameters:
sender -
session -
message -


Open Wonderland - http://openwonderland.org