Internet Chess ToolKit
v0.2.0

ictk.boardgame.chess.net.ics
Class ICSEventRouter

java.lang.Object
  extended byictk.boardgame.chess.net.ics.ICSEventRouter

public class ICSEventRouter
extends java.lang.Object

Routes ICSEvent messages to ICSEventListeners. It is possible to use one router for many live connections to different servers. At least that's an intended goal.


Constructor Summary
ICSEventRouter()
           
 
Method Summary
 void addBoardListener(ICSEventListener eh, int boardNumber, int type)
          adding this type of listener will subscribe the listener to the following types of events for this board number:
type 1: board updates, moves forward and back, resignations
type 2: takeback requests, draw offers, adjourn and pause requests
type 3: kibitzes, whispers, and board says
NOTE: all types must be registered independently
 void addChannelListener(int channelType, int channelNumber, ICSEventListener eh)
          adds a listener to a particular channel.
 void addEventListener(int icsEventNumber, ICSEventListener eh)
          tells the router that this listener would like to hear a particular type of event.
 void dispatch(ICSEvent evt)
          an event sent to this method will be relayed to all the listeners who are interested in it.
 ICSEventListener getDefaultListener()
          This listener receives all message that are not exclusively processed by some other listener.
 boolean isChannelExclusive(int channelType, int channelNumber)
          are channel events for this channel only routed to this channel's listener(s), or are they also send to the CHANNEL_EVENT listener.
 boolean isExclusive(int eventType)
           
 void removeChannelListener(int channelType, int channelNumber, ICSEventListener eh)
          removes a listener to a particular channel.
 void setChannelExclusive(int channelType, int channelNumber, boolean t)
          are channel events for this channel only routed to this channel's listener(s), or are they also send to the CHANNEL_EVENT listener.
 void setDefaultListener(ICSEventListener eh)
          This listener receives all message that are not exclusively processed by some other listener.
 void setExclusive(int eventType, boolean t)
          should the event be routed only to listeners subscribed to this event, or also to the default listener.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ICSEventRouter

public ICSEventRouter()
Method Detail

setDefaultListener

public void setDefaultListener(ICSEventListener eh)
This listener receives all message that are not exclusively processed by some other listener. Uncategorized output is also sent to the default listener.


getDefaultListener

public ICSEventListener getDefaultListener()
This listener receives all message that are not exclusively processed by some other listener. Uncategorized output is also sent to the default listener.


dispatch

public void dispatch(ICSEvent evt)
an event sent to this method will be relayed to all the listeners who are interested in it.


addEventListener

public void addEventListener(int icsEventNumber,
                             ICSEventListener eh)
tells the router that this listener would like to hear a particular type of event.

Parameters:
icsEventNumber - an ICSEvent._EVENT

setExclusive

public void setExclusive(int eventType,
                         boolean t)
should the event be routed only to listeners subscribed to this event, or also to the default listener.

Parameters:
t - if true then the default listener will not receive the event even if there are no listeners for this event.

isExclusive

public boolean isExclusive(int eventType)

addBoardListener

public void addBoardListener(ICSEventListener eh,
                             int boardNumber,
                             int type)
adding this type of listener will subscribe the listener to the following types of events for this board number:
type 1: board updates, moves forward and back, resignations
type 2: takeback requests, draw offers, adjourn and pause requests
type 3: kibitzes, whispers, and board says
NOTE: all types must be registered independently


addChannelListener

public void addChannelListener(int channelType,
                               int channelNumber,
                               ICSEventListener eh)
adds a listener to a particular channel. This is useful if you want to log particular channels, or send them to different display areas. If a listener wish to listen to all channel events then it would be better to subscribe via addEventListener().

Parameters:
channelType - is the EventType for this sort of channel. For example: ICSEvent.CHANNEL_EVENT is for normal channel tells, ICSEvent.SHOUT_EVENT is for shouts.
channelNumber - is number of the channel, or in the case of shouts is the type of shout.

removeChannelListener

public void removeChannelListener(int channelType,
                                  int channelNumber,
                                  ICSEventListener eh)
removes a listener to a particular channel.

Parameters:
channelType - is the EventType for this sort of channel. For example: ICSEvent.CHANNEL_EVENT is for normal channel tells, ICSEvent.SHOUT_EVENT is for shouts.
channelNumber - is number of the channel, or in the case of shouts is the type of shout.

setChannelExclusive

public void setChannelExclusive(int channelType,
                                int channelNumber,
                                boolean t)
are channel events for this channel only routed to this channel's listener(s), or are they also send to the CHANNEL_EVENT listener. This setting has no bearing on whether the defaultListener receives the event or not.


isChannelExclusive

public boolean isChannelExclusive(int channelType,
                                  int channelNumber)
are channel events for this channel only routed to this channel's listener(s), or are they also send to the CHANNEL_EVENT listener. This setting has no bearing on whether the defaultListener receives the event or not.


Submit a bug or feature
Visit the Website
Internet Chess ToolKit is licensed under the GPL v2 .