net.jetrix
Class Channel

java.lang.Object
  extended by java.lang.Thread
      extended by net.jetrix.Channel
All Implemented Interfaces:
Runnable, Destination

public class Channel
extends Thread
implements Destination

Game channel.

Version:
$Revision: 578 $, $Date: 2005-01-11 01:58:04 +0100 (mar., 11 janv. 2005) $
Author:
Emmanuel Bourg

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Channel()
           
Channel(ChannelConfig channelConfig)
           
 
Method Summary
 void addFilter(FilterConfig filterConfig)
          Enable a new filter for this channel.
 void close()
          Stop the channel.
 Client getClient(int slot)
          Returns the client in the specified slot.
 int getClientSlot(Client client)
          Finds the slot used in the channel by the specified client.
 ChannelConfig getConfig()
          Returns the channel configuration.
 Field getField(int slot)
          Return the field of the specified slot.
 Iterator<MessageFilter> getFilters()
           
 GameState getGameState()
          Returns the game state.
 User getPlayer(int slot)
          Returns the client in the specified slot.
 int getPlayerCount()
          Returns the number of players currently in this chanel.
 Iterator<Client> getPlayers()
          Return an iterator of players in this channel.
 Iterator<Client> getSpectators()
          Return an iterator of spectators observing this channel.
 boolean isEmpty()
           
 boolean isFull()
          Tell if the channel can accept more players.
 void process(Message m)
           
 void process(PlayerSwitchMessage m)
           
 void removeClient(Client client)
          Remove the specified client from the channel.
 void removeFilter(String filterName)
           
 void run()
          Main loop.
 void send(Message message)
          Add a message to the channel message queue.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Channel

public Channel()

Channel

public Channel(ChannelConfig channelConfig)
Method Detail

addFilter

public void addFilter(FilterConfig filterConfig)
Enable a new filter for this channel.


removeFilter

public void removeFilter(String filterName)

getFilters

public Iterator<MessageFilter> getFilters()

run

public void run()
Main loop. The channel listens for incomming messages until the server or the channel closes. Every message is first passed through the registered filters and then handled by the channel.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

close

public void close()
Stop the channel.


process

public void process(PlayerSwitchMessage m)

process

public void process(Message m)

removeClient

public void removeClient(Client client)
Remove the specified client from the channel.


send

public void send(Message message)
Add a message to the channel message queue.

Specified by:
send in interface Destination
Parameters:
message - message to add

isFull

public boolean isFull()
Tell if the channel can accept more players.

Returns:
true if the channel is full, false if not

isEmpty

public boolean isEmpty()

getPlayerCount

public int getPlayerCount()
Returns the number of players currently in this chanel.

Returns:
player count

getConfig

public ChannelConfig getConfig()
Returns the channel configuration.


getGameState

public GameState getGameState()
Returns the game state.


getClientSlot

public int getClientSlot(Client client)
Finds the slot used in the channel by the specified client.


getClient

public Client getClient(int slot)
Returns the client in the specified slot.

Parameters:
slot - slot number between 1 and 6
Returns:
null if there is no client in the specified slot, or if the number is out of range

getPlayer

public User getPlayer(int slot)
Returns the client in the specified slot.

Parameters:
slot - slot number between 1 and 6
Returns:
null if there is no client in the specified slot, or if the number is out of range

getPlayers

public Iterator<Client> getPlayers()
Return an iterator of players in this channel.


getSpectators

public Iterator<Client> getSpectators()
Return an iterator of spectators observing this channel.


getField

public Field getField(int slot)
Return the field of the specified slot.



Copyright © 2001-2008 Emmanuel Bourg. All Rights Reserved.