public class Calculator extends Tester implements CallableClient
| Modifier and Type | Class and Description | 
|---|---|
| static class  | Calculator.SendModeRepresents a delivery pattern. | 
| Modifier and Type | Field and Description | 
|---|---|
| static Calculator.SendMode | ASYNCH_MODESends messages using the Synchronous Call/Response delivery pattern. | 
| static Calculator.SendMode | NOTIFY_MODESends messages using the Notify delivery pattern. | 
| static Calculator.SendMode | RANDOM_MODESends messages using a random choice of one of the other modes. | 
| static Calculator.SendMode | SYNCH_MODESends messages using the Asynchronous Call/Response delivery pattern. | 
| Constructor and Description | 
|---|
| Calculator(HubConnection connection,
          Random random)Constructor. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | flush()Waits until all the responses this client is expecting to get 
 have been safely received. | 
| HubConnection | getConnection()Returns the hub connection used by this client. | 
| int | getReceiveCount()Returns the total number of messages received using any delivery pattern. | 
| int | getSendCount()Returns the total number of messages sent using any delivery pattern. | 
| void | receiveCall(String senderId,
           String msgId,
           Message msg)Receives a message for which a response is required. | 
| void | receiveNotification(String senderId,
                   Message msg)Receives a message for which no response is required. | 
| void | receiveResponse(String senderId,
               String msgTag,
               Response response)Receives a response to a message previously sent by this client. | 
| void | sendMessage(String receiverId,
           Calculator.SendMode mode)Sends a randomly generated message in a randomly generated way to
 a given receiver. | 
assertEquals, assertEquals, assertTrue, failpublic static final Calculator.SendMode NOTIFY_MODE
public static final Calculator.SendMode ASYNCH_MODE
public static final Calculator.SendMode SYNCH_MODE
public static final Calculator.SendMode RANDOM_MODE
public Calculator(HubConnection connection, Random random) throws SampException
connection - hub connectionrandom - random number generatorSampExceptionpublic void sendMessage(String receiverId, Calculator.SendMode mode) throws SampException
receiverId - client ID of another Calculator client.SampExceptionpublic int getSendCount()
public int getReceiveCount()
public HubConnection getConnection()
public void flush()
public void receiveNotification(String senderId, Message msg)
CallableClientreceiveNotification in interface CallableClientsenderId - public ID of sending clientmsg - messagepublic void receiveCall(String senderId, String msgId, Message msg) throws SampException
CallableClientreply
 method at some future point.receiveCall in interface CallableClientsenderId - public ID of sending clientmsgId - message identifier for later use with replymsg - messageSampExceptionpublic void receiveResponse(String senderId, String msgTag, Response response)
CallableClientreceiveResponse in interface CallableClientsenderId - public ID of responding clientmsgTag - client-defined tag labelling previously-sent messageresponse - returned response objectCopyright © 2008–2024. All rights reserved.