1 package org.testng.remote.strprotocol; 2 3 import java.io.IOException; 4 import java.net.SocketException; 5 import java.net.SocketTimeoutException; 6 7 public interface IMessageSender { 8 connect()9 void connect() throws IOException; 10 11 /** 12 * Initialize the receiver. 13 * the underlying socket server will be polling until a first client connect. 14 * 15 * @throws SocketException This exception will be thrown if a connection 16 * to the remote TestNG instance could not be established after ten 17 * seconds. 18 */ initReceiver()19 void initReceiver() throws SocketTimeoutException; 20 21 /** 22 * Stop the receiver. 23 * it provides a way that allow the API invoker to stop the receiver, 24 * e.g. break from a dead while loop 25 */ stopReceiver()26 void stopReceiver(); 27 sendMessage(IMessage message)28 void sendMessage(IMessage message) throws Exception; 29 30 /** 31 * Will return null or throw EOFException when the connection has been severed. 32 */ receiveMessage()33 IMessage receiveMessage() throws Exception; 34 shutDown()35 void shutDown(); 36 37 // These two methods should probably be in a separate class since they should all be 38 // the same for implementers of this interface. sendAck()39 void sendAck(); 40 sendStop()41 void sendStop(); 42 } 43