|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--core.Agent
This class represents an agent running a protocol
Field Summary | |
private java.lang.String |
id
The identity of the agent as written in the protocol description (for example a or b) |
private java.io.BufferedReader |
in
This BufferedReader is used by an host to receive messages that have been sent to him, with the get method |
private java.lang.String |
ip
The internet location of the agent (for example booth35.ecs.ox.ac.uk) |
private java.lang.String |
name
The name of the agent that is used for example in the KeyStores (for example Alice or Bob) |
private java.io.PrintWriter |
out
This PrintWriter is used by an host to send a message to another one, with the put method |
private java.net.Socket |
socket
The socket used to communicate with this Agent |
Constructor Summary | |
Agent()
Creates a new empty agent |
Method Summary | |
void |
contact(java.lang.String url,
int port)
creates a socket connected to (url,port) and use it to communicate with this Agent also sets the in and out accordingly |
java.lang.String |
get()
Receive data from this Agent. |
java.lang.String |
getId()
Returns the id of this agent |
java.lang.String |
getIp()
Return the IP of this Agent |
java.lang.String |
getName()
return the name of this agent |
java.net.Socket |
getSocket()
Return the Socket that has been allocated to this Agent |
void |
put(java.lang.String what,
int port)
Send data to this Agent on the given port. |
void |
setId(java.lang.String string)
sets the id of this agent |
private void |
setInAndOut()
sets the in and out private members according to the socket used |
void |
setIP(java.lang.String ip)
Changes the IP of this Agent |
void |
setName(java.lang.String string)
sets the name of this agent |
void |
setSocket(java.net.Socket socket)
sets the socket used to communicate with this Agent and the in and out accordingly |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private java.lang.String id
private java.lang.String ip
private java.lang.String name
private java.io.PrintWriter out
private java.io.BufferedReader in
private java.net.Socket socket
Constructor Detail |
public Agent()
Method Detail |
public void setIP(java.lang.String ip)
ip
- new IP to be allocated to this hostpublic java.lang.String getId()
public java.lang.String getName()
public void setId(java.lang.String string)
string
- new id of this agentpublic void setName(java.lang.String string)
string
- new name of this agentprivate void setInAndOut()
public void setSocket(java.net.Socket socket)
socket
- to use to communicate with this Agentpublic void contact(java.lang.String url, int port)
url
- internet name of the host corresponding to this Agentport
- port to use for communication with this Agentpublic void put(java.lang.String what, int port)
what
- what has to be sent to the Agentport
- port to usepublic java.lang.String get()
public java.lang.String getIp()
public java.net.Socket getSocket()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |