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) |
writeMessage
public 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 BlockingSender
shutdown
in interface Sender
shutdown
in class StreamSender
public 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 BlockingSender
message
- 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 Sender
message
- A Message
.CommunicationException
- If an error occurs.protected static final void writeMessageToStream(Message message, OutputStream stream) throws IOException
IOException
public boolean isShutdown()
true
if and only if we are shut down.Copyright © 2000-2014. All Rights Reserved.