ResponseHandler
Keywords: uk.ac.ic.doc.automed.p2p.communication.ResponseHandler 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 ResponseHandler

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

    public class ResponseHandler

extends java.lang.Object

Field Summary
`static java.lang.String` | `OUTPUT_SOCKET`
`static java.lang.String` | `OUTPUT_STREAM`
`static java.lang.String` | `REMOTE_ADDRESS`
`static java.lang.String` | `REMOTE_PORT`
`static java.lang.String` | `SRC_ADDRESS`

Constructor Summary
`ResponseHandler(java.lang.String protocol, java.util.Map handlerElements)` Creates a new instance of ResponseHandler

Method Summary
`java.lang.String` | `getRemoteAddress()` The address of the remote host to which this response is sent
`int` | `getRemotePort()` The port on the remote host at which this response is targeted
`java.net.InetAddress` | `getSourceAddress()` The address of this host used for sending response
`void` | `serialiseOutput(AbstractMessage response)`
`void` | `serialiseUDPOutput(byte[] response)` Serialise bytes

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

Field Detail

### OUTPUT_STREAM

    public static final java.lang.String OUTPUT_STREAM

See Also:
  Constant Field Values

### OUTPUT_SOCKET

    public static final java.lang.String OUTPUT_SOCKET

See Also:
  Constant Field Values

### REMOTE_ADDRESS

    public static final java.lang.String REMOTE_ADDRESS

See Also:
  Constant Field Values

### REMOTE_PORT

    public static final java.lang.String REMOTE_PORT

See Also:
  Constant Field Values

### SRC_ADDRESS

    public static final java.lang.String SRC_ADDRESS

See Also:
  Constant Field Values

Constructor Detail

### ResponseHandler

    public ResponseHandler(java.lang.String protocol,
                           java.util.Map handlerElements)

  Creates a new instance of ResponseHandler

  Parameters:
    `protocol` - communication protocol to use (see `#Constants`)
    `elements` - map of elements which help serialise the response (dependent on protocol)
    TCP:
    - `OUTPUT_STREAM` --> `OutputStream` object
    UDP:
    - `OUTPUT_SOCKET` --> `DatagramSocket` object
    - `REMOTE_ADDRESS` --> `InetAddress` of the remote host
    - `REMOTE_PORT` --> an integer indicating remote port

Method Detail

### serialiseOutput

    public void serialiseOutput(AbstractMessage response)
                         throws CommunicationException

  Throws:
    `CommunicationException`

### serialiseUDPOutput

    public void serialiseUDPOutput(byte[] response)
                            throws CommunicationException

  Serialise bytes

  Throws:
    `CommunicationException`

### getSourceAddress

    public java.net.InetAddress getSourceAddress()

  The address of this host used for sending response

### getRemoteAddress

    public java.lang.String getRemoteAddress()

  The address of the remote host to which this response is sent

### getRemotePort

    public int getRemotePort()

  The port on the remote host at which this response is targeted

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