com.mooapi.server
Class MooChannel

java.lang.Object
  extended by com.mooapi.server.MooChannel

public class MooChannel
extends java.lang.Object

This class implements MooAPI channels.

Author:
Steve Taylor

Constructor Summary
MooChannel(int id, java.lang.String name)
          Initialize a MooAPI channel.
 
Method Summary
 void disconnect()
          Bidirectionally disassociate this channel from all connections.
 int getConnectionCount()
          Get the number of connections subscribed to this channel.
 int getId()
          Get this channel's ID.
 MooConnection getMasterConnection()
          Get this channel's master connection.
 java.lang.String getName()
          Get this channel's name.
 void join(MooConnection connection)
          Notify this session that a connection has joined.
 void leave(MooConnection connection)
          Remove the specified connection from this channel, notifying all the remaining connections.
<T extends AbstractMessage>
void
sendMessage(MooConnection sourceConnection, short subchannel, T message)
          Send a message to this channel from a connection.
 void sendNameChange(MooConnection sourceConnection, java.lang.String name)
          Notify this channel of a connection name change.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MooChannel

public MooChannel(int id,
                  java.lang.String name)
Initialize a MooAPI channel.

Parameters:
id - The channel's ID.
name - The channel's name.
Method Detail

getId

public int getId()
Get this channel's ID.

Returns:
This channel's ID.

getName

public java.lang.String getName()
Get this channel's name.

Returns:
This channel's name.

getConnectionCount

public int getConnectionCount()
Get the number of connections subscribed to this channel.

Returns:
The number of connections subscribed to this channel.

sendMessage

public <T extends AbstractMessage> void sendMessage(MooConnection sourceConnection,
                                                    short subchannel,
                                                    T message)

Send a message to this channel from a connection.

The connection must be subscribed to this channel, otherwise the message is ignored.

Parameters:
sourceConnection - The connection from which the message is sent.
subchannel - The subchannel on which the message is sent.
message - The text of the message.

sendNameChange

public void sendNameChange(MooConnection sourceConnection,
                           java.lang.String name)
Notify this channel of a connection name change.

Parameters:
sourceConnection - The connection whose name changed.
name - The new name.

join

public void join(MooConnection connection)
Notify this session that a connection has joined. This causes connection on and join messages to be sent the the new and existing connections respectively.

Parameters:
connection - A new MooAPI connection.

leave

public void leave(MooConnection connection)
Remove the specified connection from this channel, notifying all the remaining connections.

Parameters:
connection - The connection to remove.

disconnect

public void disconnect()
Bidirectionally disassociate this channel from all connections.


getMasterConnection

public MooConnection getMasterConnection()
Get this channel's master connection.

Returns:
The master connection.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2009. All Rights Reserved.