com.interfaceware.chameleon
Class Connection

java.lang.Object
  extended by com.interfaceware.chameleon.Hl7ClientSocket
      extended by com.interfaceware.chameleon.Connection
All Implemented Interfaces:
Transport

public class Connection
extends Hl7ClientSocket
implements Transport

This class implements a connection for streaming data to and from a client socket.

See Also:
Transport

Field Summary
protected static int EOF
           
protected  ServerSocketListener m_Listener
           
protected  Log m_Log
           
protected  Hl7ClientSocket m_Socket
           
protected  Wrapper m_Wrapper
           
 
Constructor Summary
Connection()
          default constructor
Connection(long TransportId, Wrapper AWrapper, Log ALog)
          Constructs a Connection with the specified socket and wrapper objects, and the log interface.
 
Method Summary
 void addServerSocketListener(ServerSocketListener AListener)
          Adds the specified server socket listener to receive server socket events from this connection.
protected  void clientConnectEvent()
          /** Invokes the onClientConnect event on the ServerSocketListener class
protected  void errorEvent(java.lang.Exception Error, java.lang.String Description)
          Converts the Exception to a string and appends a description to the error message.
 void onClose(long TransportId)
          called when a connection closes
 void onMessage(long TransportId, java.lang.String Message)
          Listens on the client socket port for incoming messages.
 void onTransportError(long TransportId, int ErrorId, java.lang.String ErrorMessage)
          called when an error occurs
protected  void println(java.lang.String Description)
          Logs line to the log object assigned to this class
 void sendMessage(java.lang.String MessageData)
          Wraps a message and writes the message to the socket output stream.
 
Methods inherited from class com.interfaceware.chameleon.Hl7ClientSocket
closeConnection, connect, finalize, getAddress, getIp, onConnect, stopNetworkingThread
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_Socket

protected Hl7ClientSocket m_Socket

m_Wrapper

protected Wrapper m_Wrapper

m_Log

protected Log m_Log

m_Listener

protected ServerSocketListener m_Listener

EOF

protected static final int EOF
See Also:
Constant Field Values
Constructor Detail

Connection

public Connection()
default constructor


Connection

public Connection(long TransportId,
                  Wrapper AWrapper,
                  Log ALog)
Constructs a Connection with the specified socket and wrapper objects, and the log interface. The constructor initialises the input/output data streams for the socket and starts the thread. The wrapper is used to wrap and unwrap message data passed through the data streams. Without a wrapper, messages cannot be sent or received. When the log interface is null, error messages are written to the console.

Method Detail

onMessage

public void onMessage(long TransportId,
                      java.lang.String Message)
Listens on the client socket port for incoming messages. The incoming data is added to a buffer and the buffer is sent to the wrapper. A valid wrapper object must be passed in the constructor, in order to unwrap the incoming message.

Overrides:
onMessage in class Hl7ClientSocket
See Also:
Wrapper

sendMessage

public void sendMessage(java.lang.String MessageData)
Wraps a message and writes the message to the socket output stream. A valid wrapper object must be passed in the constructor, in order to wrap the outgoing message.

Specified by:
sendMessage in interface Transport
Overrides:
sendMessage in class Hl7ClientSocket

onTransportError

public void onTransportError(long TransportId,
                             int ErrorId,
                             java.lang.String ErrorMessage)
called when an error occurs

Overrides:
onTransportError in class Hl7ClientSocket

errorEvent

protected void errorEvent(java.lang.Exception Error,
                          java.lang.String Description)
Converts the Exception to a string and appends a description to the error message. The error message is output using the log interface passed to the constructor.


println

protected void println(java.lang.String Description)
Logs line to the log object assigned to this class


onClose

public void onClose(long TransportId)
called when a connection closes

Overrides:
onClose in class Hl7ClientSocket

clientConnectEvent

protected void clientConnectEvent()
/** Invokes the onClientConnect event on the ServerSocketListener class


addServerSocketListener

public void addServerSocketListener(ServerSocketListener AListener)
Adds the specified server socket listener to receive server socket events from this connection.