|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.cuny.cat.GameClient
public abstract class GameClient
A generic class featuring the common behavior of market (specialist) clients and trader clients.
Parameters
base.type string beginning with SELLER, BUYER, or SEPECIALIST |
the type of client |
base.id string |
the id the client wants to be assigned (optional) |
base.conntrialmax int >=1 ( 1000 by default) |
the maximum number of attempts to connect to server |
base.logging boolean ( false by default) |
whether to generate logging info |
base.report class, inherits GameReport |
a report collecting information on activiites on this market |
Default Base
game_client |
Field Summary | |
---|---|
protected ClientConnector<CatpMessage> |
clientConnector
|
protected java.lang.String |
clientId
the id of this client. |
protected ReactiveConnection<CatpMessage> |
connection
|
protected int |
connTrialMax
the maximal number of connection attempts to make |
protected Dispatcher |
dispatcher
receives and processes event-dispatching tasks. |
protected edu.cuny.event.EventEngine |
eventEngine
|
protected java.util.LinkedList<AuctionEventListener> |
eventListeners
|
protected CatpInfrastructure |
infrast
|
protected boolean |
logging
|
static java.lang.String |
P_CONNECTION_TRIAL_MAX
|
static java.lang.String |
P_DEF_BASE
|
static java.lang.String |
P_ID
|
static java.lang.String |
P_LOGGING
|
static java.lang.String |
P_REPORT
|
static java.lang.String |
P_TYPE
|
protected edu.cuny.prng.GlobalPRNG |
prng
|
protected org.apache.commons.collections15.Buffer<CatpProactiveSession> |
proactiveSessions
self-initiated on-going sessions on current trading day. |
protected CatpReactiveSession[] |
reactiveSessions
sessions that are possibly initiated by the server at the moment. |
protected ClientRegistry |
registry
|
protected GameReport |
report
data report. |
protected java.lang.String |
tag
the current catp tag that is used to validate the timestamp of messages. |
protected java.lang.String |
type
the type of this client. |
Constructor Summary | |
---|---|
GameClient()
constructors and setup |
Method Summary | |
---|---|
void |
addAuctionEventListener(AuctionEventListener listener)
auction listener related |
protected void |
addEventDispatchingTask(AuctionEvent event)
|
void |
addReport(GameReport newReport)
Add a new market data report. |
protected void |
checkAndUpdateMatchedShout(Shout matchedShout,
Shout recordedShout)
checks the information in a matched shout against the existing record. |
protected void |
cleanUpDaily()
|
protected void |
cleanUpGamely()
|
protected void |
clearPendingProactiveSessions()
|
protected void |
close()
|
protected void |
connectToServer()
connection related |
protected static Shout |
createMatchedShoutSimple(java.lang.String shoutId,
int quantity,
double price,
boolean isBid,
Specialist specialist)
creates a shout with a matched state. |
protected abstract ClientRegistry |
createRegistry()
|
protected void |
dectedAndRunReactiveSessions(CatpRequest request,
CatpReactiveSession[] sessions)
|
protected void |
dispatchEvent(AuctionEvent event)
|
protected abstract CatpReactiveSession |
getDayOpenedSessionInstance()
|
protected abstract CatpReactiveSession |
getDayOpeningSessionInstance()
|
java.lang.String |
getId()
|
GameReport |
getReport()
|
java.lang.String |
getType()
|
protected void |
loginfo(java.lang.String msg)
|
void |
messageArrived(CatpMessage msg)
message processing related |
protected abstract void |
postTransactionReceived(Transaction transaction)
This method should be implemented by TraderClient and
MarketClient respectively to check the validity of the posted
transaction. |
protected void |
printDayInfo(int day)
|
protected void |
printGameInfo()
|
protected void |
printRoundInfo(int round)
|
protected void |
processEventDispatchingTasks()
|
void |
removeAuctionEventListener(AuctionEventListener listener)
|
protected void |
reportDynamics(java.lang.String info)
debugging |
void |
reportDynamics(java.lang.String clientId,
java.lang.String info)
|
void |
run()
|
protected void |
setExpectedReactiveSession(CatpReactiveSession session)
|
protected void |
setExpectedReactiveSessions(CatpReactiveSession[] sessions)
|
void |
setId(java.lang.String clientId)
|
void |
setReport(GameReport newReport)
|
void |
setType(java.lang.String type)
|
void |
setup(edu.cuny.config.param.ParameterDatabase parameters,
edu.cuny.config.param.Parameter base)
|
protected void |
showSessions(java.lang.Object[] sessions)
|
protected void |
startProactiveSession(CatpProactiveSession session)
session related |
protected void |
testMarketTimeout()
|
protected void |
testTimeout()
|
protected void |
testTraderTimeout()
|
java.lang.String |
toString()
others |
void |
update(java.util.Observable o,
java.lang.Object arg)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface edu.cuny.cat.event.AuctionEventListener |
---|
eventOccurred |
Field Detail |
---|
public static final java.lang.String P_CONNECTION_TRIAL_MAX
public static final java.lang.String P_TYPE
public static final java.lang.String P_ID
public static final java.lang.String P_LOGGING
public static final java.lang.String P_REPORT
public static final java.lang.String P_DEF_BASE
protected ClientConnector<CatpMessage> clientConnector
protected ReactiveConnection<CatpMessage> connection
protected int connTrialMax
protected Dispatcher dispatcher
protected java.util.LinkedList<AuctionEventListener> eventListeners
protected org.apache.commons.collections15.Buffer<CatpProactiveSession> proactiveSessions
protected CatpReactiveSession[] reactiveSessions
protected java.lang.String type
protected java.lang.String clientId
protected ClientRegistry registry
protected GameReport report
protected java.lang.String tag
protected boolean logging
protected CatpInfrastructure infrast
protected edu.cuny.event.EventEngine eventEngine
protected edu.cuny.prng.GlobalPRNG prng
Constructor Detail |
---|
public GameClient()
Method Detail |
---|
protected abstract ClientRegistry createRegistry()
public void setup(edu.cuny.config.param.ParameterDatabase parameters, edu.cuny.config.param.Parameter base)
setup
in interface edu.cuny.config.param.Parameterizable
protected void cleanUpGamely()
protected void cleanUpDaily()
public java.lang.String getId()
public void setId(java.lang.String clientId)
public java.lang.String getType()
public void setType(java.lang.String type)
public void addReport(GameReport newReport)
newReport
- The new report to add.public void setReport(GameReport newReport)
public GameReport getReport()
protected void connectToServer()
protected void close()
public void run()
run
in interface java.lang.Runnable
protected void startProactiveSession(CatpProactiveSession session)
protected void setExpectedReactiveSession(CatpReactiveSession session)
protected void setExpectedReactiveSessions(CatpReactiveSession[] sessions)
protected void dectedAndRunReactiveSessions(CatpRequest request, CatpReactiveSession[] sessions)
protected void clearPendingProactiveSessions()
protected abstract CatpReactiveSession getDayOpeningSessionInstance()
protected abstract CatpReactiveSession getDayOpenedSessionInstance()
protected static Shout createMatchedShoutSimple(java.lang.String shoutId, int quantity, double price, boolean isBid, Specialist specialist)
shoutId
- quantity
- price
- isBid
- specialist
-
protected void checkAndUpdateMatchedShout(Shout matchedShout, Shout recordedShout)
matchedShout
- the matched shoutrecordedShout
- the existing record of the matched shout, which is from the local
registryprotected abstract void postTransactionReceived(Transaction transaction)
TraderClient
and
MarketClient
respectively to check the validity of the posted
transaction.
transaction
- the posted transactionpublic void addAuctionEventListener(AuctionEventListener listener)
public void removeAuctionEventListener(AuctionEventListener listener)
protected void dispatchEvent(AuctionEvent event)
protected void addEventDispatchingTask(AuctionEvent event)
protected void processEventDispatchingTasks()
public void update(java.util.Observable o, java.lang.Object arg)
update
in interface java.util.Observer
public void messageArrived(CatpMessage msg)
messageArrived
in interface ConnectionListener<CatpMessage>
public java.lang.String toString()
toString
in class java.lang.Object
protected void reportDynamics(java.lang.String info)
public void reportDynamics(java.lang.String clientId, java.lang.String info)
protected void showSessions(java.lang.Object[] sessions)
protected void printGameInfo()
protected void printDayInfo(int day)
protected void printRoundInfo(int round)
protected void loginfo(java.lang.String msg)
protected void testMarketTimeout()
protected void testTraderTimeout()
protected void testTimeout()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |