| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
edu.cuny.cat.server.ConnectionManager
public final class ConnectionManager
A class, as a thread, accepts connection requests, creates
 ConnectionAdaptors, and manage them, including event passing, etc..
| Nested Class Summary | 
|---|
| Nested classes/interfaces inherited from class java.lang.Thread | 
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler | 
| Field Summary | |
|---|---|
protected  java.util.SortedMap<java.lang.String,ConnectionAdaptor> | 
adaptors
normal connections  | 
protected  java.util.Set<ConnectionAdaptor> | 
babyAdaptors
connections with clients that have yet to check in.  | 
protected  GameController | 
controller
 | 
protected  Dispatcher | 
dispatcher
a separate thread to process event-dispatching tasks  | 
protected  IdentityOffice | 
identityOffice
 | 
protected  CatpInfrastructure | 
infrast
 | 
protected  ServerConnector<CatpMessage> | 
serverConnector
 | 
protected  boolean | 
stopAcceptingConnection
 | 
protected  edu.cuny.random.Uniform | 
uniform
used to randomize event dispatching order  | 
| Fields inherited from class java.lang.Thread | 
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY | 
| Constructor Summary | |
|---|---|
ConnectionManager()
 | 
|
| Method Summary | ||
|---|---|---|
 void | 
clientCheckIn(ConnectionAdaptor adaptor)
processes the connection adaptor over which a client checked in.  | 
|
 void | 
dispatchEvent(AuctionEvent event)
dispatches an event to all clients  | 
|
 void | 
dispatchEvent(AuctionEvent event,
              java.util.Collection<java.lang.String> receiverIdColl)
dispatches an event to specified client receivers.  | 
|
 void | 
dispatchEvent(AuctionEvent event,
              java.util.Collection<java.lang.String> receiverIdColl,
              java.util.Observer observer)
 | 
|
 void | 
dispatchIncomingMessage(CatpMessage msg,
                        MessageHandler<CatpMessage> handler,
                        java.lang.String clientId,
                        java.util.Observer observer)
aims to enqueue messages incoming from clients and get them process in order along with events.  | 
|
 void | 
dispatchOutgoingMessage(CatpMessage msg,
                        Session<CatpMessage> session,
                        java.lang.String clientId,
                        java.util.Observer observer)
aims to enqueue all messages outgoing to clients and get them sent in order.  | 
|
 void | 
eventOccurred(AuctionEvent event)
process event without forwarding to connection adaptors  | 
|
 ConnectionAdaptor | 
getAdaptor(java.lang.String clientId)
 | 
|
 IdentityOffice | 
getIdentityOffice()
 | 
|
 void | 
printPendingTasks()
prints all the pending tasks enqueued, for debugging purpose only.  | 
|
 void | 
processDispatchingTasks()
 | 
|
 void | 
processEventLocally(AuctionEvent event)
 | 
|
 | 
randomize(T[] array)
randomize the order of objects in an array.  | 
|
 void | 
removeAdaptor(java.lang.String clientId)
 | 
|
 void | 
removeBabyAdaptor(ConnectionAdaptor adaptor)
 | 
|
 void | 
run()
 | 
|
protected  void | 
stopAcceptingConnection()
 | 
|
 void | 
terminate()
terminiates the connections and the event dispatcher.  | 
|
| Methods inherited from class java.lang.Thread | 
|---|
activeCount, checkAccess, clone, 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 | 
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
protected CatpInfrastructure infrast
protected GameController controller
protected ServerConnector<CatpMessage> serverConnector
protected boolean stopAcceptingConnection
protected IdentityOffice identityOffice
protected java.util.SortedMap<java.lang.String,ConnectionAdaptor> adaptors
protected java.util.Set<ConnectionAdaptor> babyAdaptors
protected Dispatcher dispatcher
protected edu.cuny.random.Uniform uniform
| Constructor Detail | 
|---|
public ConnectionManager()
| Method Detail | 
|---|
public IdentityOffice getIdentityOffice()
public void terminate()
public void run()
run in interface java.lang.Runnablerun in class java.lang.Threadprotected void stopAcceptingConnection()
public void removeBabyAdaptor(ConnectionAdaptor adaptor)
public void removeAdaptor(java.lang.String clientId)
public ConnectionAdaptor getAdaptor(java.lang.String clientId)
public void clientCheckIn(ConnectionAdaptor adaptor)
adaptor - the connection adaptor for the client that just checked in.public void eventOccurred(AuctionEvent event)
eventOccurred in interface AuctionEventListenerevent - public void processEventLocally(AuctionEvent event)
public void dispatchEvent(AuctionEvent event)
event - 
public void dispatchEvent(AuctionEvent event,
                          java.util.Collection<java.lang.String> receiverIdColl)
event - receiverIdColl - 
public void dispatchEvent(AuctionEvent event,
                          java.util.Collection<java.lang.String> receiverIdColl,
                          java.util.Observer observer)
public void dispatchOutgoingMessage(CatpMessage msg,
                                    Session<CatpMessage> session,
                                    java.lang.String clientId,
                                    java.util.Observer observer)
msg - session - clientId - observer - 
public void dispatchIncomingMessage(CatpMessage msg,
                                    MessageHandler<CatpMessage> handler,
                                    java.lang.String clientId,
                                    java.util.Observer observer)
msg - handler - clientId - observer - public void processDispatchingTasks()
public void printPendingTasks()
public <T> T[] randomize(T[] array)
T - the type of elements in the array.array - the array
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||