|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.cuny.cat.comm.CallBasedInfrastructureImpl
public class CallBasedInfrastructureImpl
The class implements a method-invocation-based infrastructure for catp.
With this infrstructure implementation, both the game server and the clients
share a single control thread, which also runs the game clock, unlike the
multi-threading scheme in SocketBasedInfrastructureImpl
and
QueueBasedInfrastructureImpl
. This implies that all parties run
inside a single process, similar to what happens in JASA. This
single-threading scheme overlooks the length of trading rounds, round breaks,
day breaks, and the like, therefore is expected to be much faster than the
asynchronous infrstructure implementations that have to configure with
sufficiently long rounds to allow message passing among the game server and
the clients.
It is worth noting that though there is a single control thread most of the game duration, a game client may have a separate thread to set itself up during the game initialization period.
Parameters
Default Base
call_based_infrastructure |
Field Summary | |
---|---|
protected java.util.Map<java.lang.Object,CallBasedCatpConnection> |
connections
|
protected edu.cuny.util.IdAllocator |
idAllocator
|
static java.lang.String |
P_DEF_BASE
|
protected org.apache.commons.collections15.Buffer<CallBasedCatpClientConnector> |
waitingClients
|
Constructor Summary | |
---|---|
CallBasedInfrastructureImpl()
|
Method Summary | |
---|---|
CallBasedCatpConnection |
acceptClient(CallBasedCatpServerConnector server)
|
void |
cleanUp()
cleans up after finishing using this infrastructure. |
void |
closeConnection(java.lang.Object connector)
|
CallBasedCatpConnection |
connectToServer(CallBasedCatpClientConnector client)
|
ClientConnector<CatpMessage> |
createClientConnector()
can be invoked by a GameClient to create a
ClientConnector so as to connect to a
GameServer . |
ServerConnector<CatpMessage> |
createServerConnector()
can be invoked by a GameServer to create a
ServerConnector so as to be able to wait for connection requests
from GameClient s. |
void |
freeServerConnector(CallBasedCatpServerConnector server)
frees the waiting ServerConnector . |
static CallBasedInfrastructureImpl |
getInstance()
|
boolean |
isSynchronous()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String P_DEF_BASE
protected org.apache.commons.collections15.Buffer<CallBasedCatpClientConnector> waitingClients
protected java.util.Map<java.lang.Object,CallBasedCatpConnection> connections
protected edu.cuny.util.IdAllocator idAllocator
Constructor Detail |
---|
public CallBasedInfrastructureImpl()
Method Detail |
---|
public static CallBasedInfrastructureImpl getInstance()
public ClientConnector<CatpMessage> createClientConnector()
Infrastructure
GameClient
to create a
ClientConnector
so as to connect to a
GameServer
.
createClientConnector
in interface Infrastructure<CatpMessage>
CallBasedCatpClientConnector
.public ServerConnector<CatpMessage> createServerConnector()
Infrastructure
GameServer
to create a
ServerConnector
so as to be able to wait for connection requests
from GameClient
s.
createServerConnector
in interface Infrastructure<CatpMessage>
CallBasedCatpServerConnector
.public CallBasedCatpConnection connectToServer(CallBasedCatpClientConnector client)
public CallBasedCatpConnection acceptClient(CallBasedCatpServerConnector server) throws ConnectionException
ConnectionException
public void freeServerConnector(CallBasedCatpServerConnector server)
ServerConnector
.
server
- the waiting ServerConnector
.public void cleanUp()
Infrastructure
cleanUp
in interface Infrastructure<CatpMessage>
public void closeConnection(java.lang.Object connector)
public boolean isSynchronous()
isSynchronous
in interface Infrastructure<CatpMessage>
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |