cdev.clip
Class ClipService

java.lang.Object
  |
  +--cdev.clip.ClipService

public class ClipService
extends java.lang.Object
implements java.lang.Runnable, IOService, TransactionResponseListener


Constructor Summary
ClipService()
          Default constructor is used by clients to create a connection to a server using a subsequent connect call.
ClipService(java.net.Socket s, TransactionListener l)
          Construct a CLIP I/O service connected to the specified socket, and with incoming traffic directed to the specified listener.
 
Method Summary
 void cancel(DeviceTransaction dt)
          Cancel a transaction.
 void connect(java.lang.String host, int port)
           
 void disconnect()
           
 void flush()
          Flush any buffered I/O.
 java.lang.String getHostName()
           
static IOService getIOService()
          Return an instance of this I/O service.
 int getPort()
           
 void handleResponse(DeviceTransaction ev)
          Handle a response to a transaction originated by an incoming request from this object.
 void initialize()
           
 boolean isConnected()
           
 void post(DeviceTransaction dt)
          post: Post a transaction.
 void reconnect()
           
 void run()
          The run method continuously reads the socket for inbound messages.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClipService

public ClipService()
Default constructor is used by clients to create a connection to a server using a subsequent connect call. Incoming traffic is passed to cdev.ControlSystem, assuming that it is a response to a Device I/O call.

ClipService

public ClipService(java.net.Socket s,
                   TransactionListener l)
            throws java.io.IOException
Construct a CLIP I/O service connected to the specified socket, and with incoming traffic directed to the specified listener. This form is used by servers creating new client handlers.
Method Detail

getIOService

public static IOService getIOService()
Return an instance of this I/O service. In this case, a static instance is returned for use by the Device class.

post

public void post(DeviceTransaction dt)
          throws java.io.IOException
post: Post a transaction. First, the transaction is serialized into an output buffer. If a byte threshold is then exceeded, the buffer is transmitted. The buffer is also transmitted if a maximum number of transactions have been buffered. Behavior is a function of transaction state, used to distinguish between new client requests, and server responses
Specified by:
post in interface IOService

handleResponse

public void handleResponse(DeviceTransaction ev)
Handle a response to a transaction originated by an incoming request from this object. (Server). This interface is defined by the interface TransactionResponseListener.
Specified by:
handleResponse in interface TransactionResponseListener

flush

public void flush()
           throws java.io.IOException
Flush any buffered I/O.
Specified by:
flush in interface IOService

cancel

public void cancel(DeviceTransaction dt)
            throws java.io.IOException
Cancel a transaction. Currently converts monitorOn to monitorOff. Others are ignored.
Specified by:
cancel in interface IOService

run

public void run()
The run method continuously reads the socket for inbound messages. Messages are forwarded to either cdev.ControlSystem (client mode) or to the listener specified in the constructor.
Specified by:
run in interface java.lang.Runnable

connect

public void connect(java.lang.String host,
                    int port)
             throws java.lang.Exception
Specified by:
connect in interface IOService

reconnect

public void reconnect()
               throws java.lang.Exception
Specified by:
reconnect in interface IOService

initialize

public void initialize()
                throws java.io.IOException

disconnect

public void disconnect()
Specified by:
disconnect in interface IOService

isConnected

public final boolean isConnected()
Specified by:
isConnected in interface IOService

getHostName

public java.lang.String getHostName()
Specified by:
getHostName in interface IOService

getPort

public int getPort()
Specified by:
getPort in interface IOService