com.h3c.util.net.msg

## Class RequestResponseConversation

- java.lang.Object
- - com.h3c.util.net.msg.Conversation
  - - com.h3c.util.net.msg.RequestResponseConversation

-     public class RequestResponseConversation
      extends Conversation

  Base implementation of a simple synchronous request/response conversation.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `RequestResponseConversation.Provider` Provider and tracker of generic request response conversations.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RequestResponseConversation(String topic, int id, int parentId)` Create a request/response conversation using the specified executor

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `acceptMessage(byte[] message)` Accept a byte form of a message in the context of a given conversation.
    `byte[]` | `sendRequest(byte[] request)` Sends the specified request, and waits indefinitely for the response.
    `byte[]` | `sendRequest(byte[] request, long timeout)` Sends the specified request, and waits the given number of milliseconds for the response.

    - ### Methods inherited from class com.h3c.util.net.msg.Conversation

      `connection, equals, hashCode, id, isEnded, parentId, setConnection, topic`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RequestResponseConversation

          public RequestResponseConversation(String topic,
                                     int id,
                                     int parentId)

      Create a request/response conversation using the specified executor
      Parameters:
        `topic` - conversation topic
        `id` - unique conversation id
        `parentId` - unique conversation id of the parent conversation; 0 if no parent conversation

  - ### Method Detail

    - #### acceptMessage

          public final void acceptMessage(byte[] message)

      Description copied from class: `Conversation`
      Accept a byte form of a message in the context of a given conversation.
      Specified by:
        `acceptMessage` in class `Conversation`
      Parameters:
        `message` - byte buffer containing the raw message

    - #### sendRequest

          public byte[] sendRequest(byte[] request,
                           long timeout)

      Sends the specified request, and waits the given number of milliseconds for the response.
      Parameters:
        `request` - request byte array
        `timeout` - timeout period in milliseconds
      Returns:
        response byte array; null if the thread was interrupted or response was not received due to timeout

    - #### sendRequest

          public byte[] sendRequest(byte[] request)

      Sends the specified request, and waits indefinitely for the response.
      Parameters:
        `request` - request byte array
      Returns:
        response byte array; null if the thread was interrupted

Copyright © 2014. All Rights Reserved.