13.17 Listener Class
The Listener class encapsulates the ability to listen for Messages, on behalf of registered Agents, at specified queues.
Table 13-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. |
13.17.1 Listener()
Listener class constructor.
| Syntax | Description |
|---|---|
Listener( const Connection* conn); |
Creates a |
Listener( const Connection* conn vector<Agent> &aglist, int waitTime=0); |
Creates a |
| Parameter | Description |
|---|---|
conn |
The connection of the new |
aglist |
The list of agents on behalf of which the |
waitTime |
The time to wait on queues for messages of interest for the clients; in seconds. |
13.17.2 getAgentList()
Retrieves the list of Agents for which the Listener provides its services.
Syntax
vector<Agent> getAgentList() const;
13.17.3 getTimeOutForListen()
Retrieves the time out for a call.
Syntax
int getTimeOutForListen() const;
13.17.4 listen()
Listens for Messages on behalf of specified Agents for the amount of time specified by a previous setTimeOutForListen() call. Returns the Agent for which there is a Message.
Note that this is a blocking call. Before this call, complete the following steps:
-
Registers each Agent listener through a setAgentList() call.
-
Make a blocking call to setTimeOutForListen() that returns when a
Messagefor one of theAgents on the list arrives. If noMessages arrive before the wait time expires, the call returns an error.
Syntax
Agent listen();
13.17.5 setAgentList()
Specifies the list of Agents for which the Listener provides its services.
Syntax
void setAgentList( vector<Agent>& agList);
| Parameter | Description |
|---|---|
agList |
The list of |
13.17.6 setTimeOutForListen()
Specifies the time out for a listen() call.
Syntax
void setTimeOutForListen( int waitTime);
| Parameter | Description |
|---|---|
waitTime |
The time interval, in seconds, during which the |