AbstractClient
Keywords: uk.ac.ic.doc.automed.p2p.communication.AbstractClient class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uk.ac.ic.doc.automed.p2p.communication
Class AbstractClient

    java.lang.Object
      uk.ac.ic.doc.automed.p2p.communication.AbstractClient

All Implemented Interfaces:
  Threadable

Direct Known Subclasses:
  TCPClient, UDPClient

    public abstract class AbstractClient

extends java.lang.Object
implements Threadable

Field Summary
`protected boolean` | `ackExpected`
`protected byte[]` | `dataToSend`
`protected RequestListener` | `handler`
`protected boolean` | `isReady`
`protected java.lang.String` | `serverHostName`
`protected int` | `serverPort`

Constructor Summary
`AbstractClient(RequestListener handler)` Create a client with no fixed specification of destination hosts
`AbstractClient(java.lang.String serverHostName, int serverPort, RequestListener handler)`
`AbstractClient(java.lang.String serverHostName, int serverPort, RequestListener handler, byte[] dataToSend)`

Method Summary
`RequestListener` | `getHandlerObject()` Return reference to `RequestListener` (handler) object
`boolean` | `getReadyState()` Always true
`abstract void` | `handleAction()` Handle thread's interrupted action
`abstract void` | `runAction()` Implement communication process
`void` | `setDataToSend(java.lang.String serverHostName, int serverPort, byte[] dataToSend, boolean ackExpected)` Set the data to send (with acknowledgement specified).
`protected void` | `setReadyState(boolean state)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### serverHostName

    protected java.lang.String serverHostName

### serverPort

    protected int serverPort

### handler

    protected RequestListener handler

### dataToSend

    protected byte[] dataToSend

### ackExpected

    protected boolean ackExpected

### isReady

    protected boolean isReady

Constructor Detail

### AbstractClient

    public AbstractClient(RequestListener handler)

  Create a client with no fixed specification of destination hosts

### AbstractClient

    public AbstractClient(java.lang.String serverHostName,
                          int serverPort,
                          RequestListener handler)

### AbstractClient

    public AbstractClient(java.lang.String serverHostName,
                          int serverPort,
                          RequestListener handler,
                          byte[] dataToSend)

Method Detail

### setDataToSend

    public void setDataToSend(java.lang.String serverHostName,
                              int serverPort,
                              byte[] dataToSend,
                              boolean ackExpected)

  Set the data to send (with acknowledgement specified). This overrides
  {@link setDataToSend(byte[] dataToSend).

  This method is used for clients which need to send messages to different
  targets at different times. An example would be a messaging client of a peer
  that needs to answer requests coming from different peers on the network.

  Parameters:
    `serverHostName` - address of remote host to send
    `serverPort` - port on remote host
    `dataToSend` - an array of bytes to send via UDP
    `ackExpected` - whether or not to expect an acknowledgement

### getReadyState

    public boolean getReadyState()

  Always true

  Specified by:
    `getReadyState` in interface `Threadable`

### setReadyState

    protected void setReadyState(boolean state)

### getHandlerObject

    public RequestListener getHandlerObject()

  Return reference to `RequestListener` (handler) object

### runAction

    public abstract void runAction()
                            throws AutoMedException

  Implement communication process

  Specified by:
    `runAction` in interface `Threadable`
  Throws:
    `AutoMedException`

### handleAction

    public abstract void handleAction()

  Handle thread's interrupted action

  Specified by:
    `handleAction` in interface `Threadable`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD