public final class ClientSender extends StreamSender implements BlockingSender
BlockingSender.NoResponseException| Modifier and Type | Method and Description |
|---|---|
Message |
blockingSend(Message message)
Send the given message and await a response.
|
static ClientSender |
connect(ClientReceiver clientReceiver)
Factory method that makes a
Sender around the existing TCP
connection owned by the supplied ClientReceiver. |
static ClientSender |
connect(Connector connector,
Address address)
Factory method that makes a TCP connection and returns a corresponding
Sender. |
boolean |
isShutdown()
Return whether we are shutdown.
|
void |
send(Message message)
Send the given message.
|
void |
sendKeepAlive()
Send a no-op message that keeps this connection alive.
|
void |
shutdown()
Cleanly shutdown the
Sender. |
protected static void |
writeMessageToStream(Message message,
OutputStream stream) |
writeMessagepublic static ClientSender connect(Connector connector, Address address) throws CommunicationException
Sender.
This class only supports synchronous communication, so the server can only
use address for identification purposes. For asynchronous
communication, see ClientReceiver.
connector - Connector to use to make the connection to the server.address - Identifies the client process.CommunicationException - If failed to connect.public static ClientSender connect(ClientReceiver clientReceiver) throws CommunicationException
Sender around the existing TCP
connection owned by the supplied ClientReceiver.clientReceiver - We create a paired Sender for this
Receiver.CommunicationException - If failed to connect.public void shutdown()
Sender. Ignore most errors,
connection has probably been reset by peer.shutdown in interface BlockingSendershutdown in interface Sendershutdown in class StreamSenderpublic Message blockingSend(Message message) throws CommunicationException
The input stream is that of our socket. This method should only be used where the sender can guarantee that the input stream will be free for exclusive use - we don't lock out external processes from interrupting the stream.
blockingSend in interface BlockingSendermessage - A Message.CommunicationException - If an error occurs.public void sendKeepAlive()
throws CommunicationException
CommunicationException - If the connection has been terminated.public final void send(Message message) throws CommunicationException
send in interface Sendermessage - A Message.CommunicationException - If an error occurs.protected static final void writeMessageToStream(Message message, OutputStream stream) throws IOException
IOExceptionpublic boolean isShutdown()
true if and only if we are shut down.Copyright © 2000-2014. All Rights Reserved.