|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectLectureGame.Test.network_stresstest.playerAgent
public class playerAgent
Created by IntelliJ IDEA. User: olekrst Date: 04.apr.2007 Time: 10:41:21 A playerAgent instance has the properties of a student client connected to the server, i.e. it has a username with an assiociated password, it has a lecture code which it will send and it will receive and send answers to questions. The agent answers the question randomly and a at a random time during or a litte after the timelimit for answering has passed. This is to emulate that not all answer the question simoultanously. An improvement of this class will be to have better answering heuristics such as a tendency to answer towards the end of the given timelimit.
Nested Class Summary | |
---|---|
private static class |
playerAgent.WorkState
|
Field Summary | |
---|---|
private int |
answerIndex
|
private int |
inputState
|
private java.io.BufferedInputStream |
is
|
private java.lang.String |
lectureCode
|
private java.lang.String |
name
|
private java.io.PrintWriter |
os
|
private java.lang.String |
password
|
private int |
protocolState
|
private java.lang.String |
quedQuestion
|
private long |
replyTimeDelay
|
private long |
replyTimer
|
private java.net.Socket |
sc
|
private playerAgent.WorkState |
state
|
Constructor Summary | |
---|---|
playerAgent(java.lang.String name,
java.lang.String password)
A player agent is created using by giving her a username and a password. |
Method Summary | |
---|---|
void |
close()
closes the socket and associated streams |
void |
connect()
Connects to the server. |
void |
doWork()
This is the core method called from the StressTester class on the agent to make it process any availiable indata from the server, or evaluate if it should answer questions |
void |
login()
Ehen a client is connected, it must log in to the server using its username and password |
private void |
parse(java.lang.String received)
Parses a received string. |
private java.lang.String |
receive()
This method is derived directly and unmodified from the receive() method in LectureGame.Core.StudentClient |
private void |
send(java.lang.String str)
Sends a string over the socket connection |
private void |
sendQuestion()
Sends a question reply over the socket |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.String name
private java.lang.String password
private java.lang.String lectureCode
private java.net.Socket sc
private playerAgent.WorkState state
private java.lang.String quedQuestion
private long replyTimeDelay
private long replyTimer
private java.io.PrintWriter os
private java.io.BufferedInputStream is
private int protocolState
private int inputState
private int answerIndex
Constructor Detail |
---|
public playerAgent(java.lang.String name, java.lang.String password)
name
- username of the agentpassword
- passwordNamesPasswords
Method Detail |
---|
public void connect() throws java.io.IOException
java.io.IOException
public void login()
public void doWork() throws java.io.IOException
java.io.IOException
private java.lang.String receive()
private void parse(java.lang.String received) throws java.io.IOException
received
-
java.io.IOException
private void send(java.lang.String str)
str
- the string to be sendtprivate void sendQuestion()
public void close() throws java.io.IOException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |