The Listener
class encapsulates the ability to listen for Message
s, on behalf of registered Agent
s, at specified queues.
Table 12-23 Summary of Listener Methods
Method | Summary |
---|---|
|
|
Retrieves the list of |
|
Retrieves the time out for a call. |
|
Listens for |
|
Specifies the list of |
|
Specifies the time out for a listen() call. |
Listener
class constructor.
Syntax | Description |
---|---|
Listener( const Connection* conn); |
Creates a Listener object. |
Listener( const Connection* conn vector<Agent> &aglist, int waitTime=0); |
Creates a Listener object and sets the list of Agent s on behalf of which it listens on queues. Also sets the waiting time; default: no waiting. |
Parameter | Description |
---|---|
conn |
The connection of the new Listener object. |
aglist |
The list of agents on behalf of which the Listener object waits on queues; clients of this Listener . |
waitTime |
The time to wait on queues for messages of interest for the clients; in seconds. |
Retrieves the list of Agent
s for which the Listener
provides its services.
vector<Agent> getAgentList() const;
Retrieves the time out for a call.
int getTimeOutForListen() const;
Listens for Message
s on behalf of specified Agent
s for the amount of time specified by a previous setTimeOutForListen() call. Returns the Agent
for which there is a Message
.
Agent listen();
Note:
This is a blocking call. Prior to this call, complete the following steps:Registers each Agent listener through a setAgentList() call.
Make a blocking call to setTimeOutForListen() that will return when a Message
for one of the Agent
s on the list arrives. If no Message
s arrive before the wait time expires, the call returns an error.
Specifies the list of Agent
s for which the Listener
provides its services.
void setAgentList( vector<Agent>& agList);
Parameter | Description |
---|---|
agList |
The list of Agent s. |
Specifies the time out for a listen() call.
void setTimeOutForListen( int waitTime);
Parameter | Description |
---|---|
waitTime |
The time interval, in seconds, during which the Listener is waiting for Message s at specified queues. |