net.grinder.communication
Class StreamSender

java.lang.Object
  extended by net.grinder.communication.StreamSender
All Implemented Interfaces:
Sender
Direct Known Subclasses:
ClientSender

public class StreamSender
extends Object

Class that manages the sending of messages to a server.

Author:
Philip Aston

Constructor Summary
StreamSender(OutputStream outputStream)
          Constructor.
 
Method Summary
 boolean isShutdown()
          Return whether we are shutdown.
 void send(Message message)
          Send the given message.
 void shutdown()
          Cleanly shutdown the Sender.
protected  void writeMessage(Message message)
          Send a message.
protected static void writeMessageToStream(Message message, OutputStream stream)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamSender

public StreamSender(OutputStream outputStream)
Constructor.

Parameters:
outputStream - The output stream to write to.
Method Detail

writeMessage

protected final void writeMessage(Message message)
                           throws IOException
Send a message.

Parameters:
message - The message.
Throws:
IOException - If an error occurs.

shutdown

public void shutdown()
Cleanly shutdown the Sender. Ignore most errors, connection has probably been reset by peer.

Specified by:
shutdown in interface Sender

send

public final void send(Message message)
                throws CommunicationException
Send the given message.

Specified by:
send in interface Sender
Parameters:
message - A Message.
Throws:
CommunicationException - If an error occurs.

writeMessageToStream

protected static final void writeMessageToStream(Message message,
                                                 OutputStream stream)
                                          throws IOException
Throws:
IOException

isShutdown

public boolean isShutdown()
Return whether we are shutdown.

Returns:
true if and only if we are shut down.


Copyright © 2000-2013. All Rights Reserved.