com.javaparts.dde
Class Conversation

java.lang.Object
  extended bycom.javaparts.dde.Conversation

public class Conversation
extends java.lang.Object

This class represents a conversation with DDE server. Conversation is established on basis of service/topic pair. The following transactions are supported:

If synchronous transaction takes longer to execute then timeout specified then synchronous method throws DDEException. You can set default timeout value for all synchronous transactions with setDefaultTimeout method. Asynchronous transaction methods return immediately and their result can be obtained from AsyncCompletedEvent. Advice transactions add items for DDE server to notify about their changes. You get these notifications via ItemChangedEvent.

See Also:
DDEEventListener

Constructor Summary
protected Conversation(java.lang.String service, java.lang.String topic, com.javaparts.dde.DDEThread dde, long conversationId)
          Creates a new instance of Conversation.
 
Method Summary
 void close()
          Close this conversation with DDE server.
 void execute(java.lang.String cmd)
          Perform synchronous execute transaction with default timeout.
 void execute(java.lang.String cmd, int timeout)
          Perform synchronous execute transaction.
 void executeAsync(java.lang.String cmd)
          Perform asynchronous execute transaction.
 void executeAsync(java.lang.String cmd, java.lang.String tid)
          Perform asynchronous execute transaction.
 java.lang.String getService()
          Get service name of the conversation.
 java.lang.String getTopic()
          Get topic name of the conversation.
 void poke(java.lang.String item, byte[] value)
          Perform synchronous poke transaction with default timeout.
 void poke(java.lang.String item, byte[] value, int timeout)
          Perform synchronous poke transaction.
 void pokeAsync(java.lang.String item, byte[] value)
          Perform asynchronous poke transaction.
 void pokeAsync(java.lang.String item, byte[] value, java.lang.String tid)
          Perform asynchronous poke transaction.
 byte[] request(java.lang.String item)
          Perform synchronous request transaction with default timeout.
 byte[] request(java.lang.String item, int timeout)
          Perform synchronous request transaction.
 void requestAsync(java.lang.String item)
          Perform asynchronous request transaction.
 void requestAsync(java.lang.String item, java.lang.String tid)
          Perform asynchronous request transaction.
 void setDefaultTimeout(int timeout)
          Set default timeout for all synchronous transactions in this conversation.
 void startAdvice(java.lang.String item)
          Perform start advice transaction with default timeout.
 void startAdvice(java.lang.String item, int timeout)
          Perform start advice transaction.
 void stopAdvice(java.lang.String item)
          Perform stop advice transaction with default timeout.
 void stopAdvice(java.lang.String item, int timeout)
          Perform stop advice transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Conversation

protected Conversation(java.lang.String service,
                       java.lang.String topic,
                       com.javaparts.dde.DDEThread dde,
                       long conversationId)
Creates a new instance of Conversation. You cannot directly create Conversation objects with this constructor. But you obtain new conversations with DDEClient.connect method.

Method Detail

request

public byte[] request(java.lang.String item,
                      int timeout)
               throws DDEException
Perform synchronous request transaction.

Parameters:
item - item name
timeout - timeout in miliseconds
Returns:
item value in form of byte array
Throws:
DDEException - if there is no such item, conversation is closed, or timeout is reached.

request

public byte[] request(java.lang.String item)
               throws DDEException
Perform synchronous request transaction with default timeout.

Parameters:
item - item name
Returns:
item value in form of byte array
Throws:
DDEException - if there is no such item, conversation is closed, or timeout is reached.

requestAsync

public void requestAsync(java.lang.String item,
                         java.lang.String tid)
                  throws DDEException
Perform asynchronous request transaction.

Parameters:
item - item name
tid - transaction identification
Throws:
DDEException - if conversation is closed.

requestAsync

public void requestAsync(java.lang.String item)
                  throws DDEException
Perform asynchronous request transaction. Equivalent to requestAsync(item, "REQUEST_"+item).

Parameters:
item - item name
Throws:
DDEException - if conversation is closed.

execute

public void execute(java.lang.String cmd,
                    int timeout)
             throws DDEException
Perform synchronous execute transaction.

Parameters:
cmd - command to execute
timeout - timeout in miliseconds
Throws:
DDEException - if given command is not accepted by the server, conversation is closed, or timeout is reached.

execute

public void execute(java.lang.String cmd)
             throws DDEException
Perform synchronous execute transaction with default timeout.

Parameters:
cmd - command to execute
Throws:
DDEException - if given command is not accepted by the server, conversation is closed, or timeout is reached.

executeAsync

public void executeAsync(java.lang.String cmd,
                         java.lang.String tid)
                  throws DDEException
Perform asynchronous execute transaction.

Parameters:
cmd - command to execute
tid - transaction identification
Throws:
DDEException - if conversation is closed.

executeAsync

public void executeAsync(java.lang.String cmd)
                  throws DDEException
Perform asynchronous execute transaction. Equivalent to executeAsync(cmd, "EXECUTE_"+cmd).

Parameters:
cmd - command to execute
Throws:
DDEException - if conversation is closed.

poke

public void poke(java.lang.String item,
                 byte[] value,
                 int timeout)
          throws DDEException
Perform synchronous poke transaction.

Parameters:
item - name of the item to update
value - new item value
timeout - timeout in miliseconds
Throws:
DDEException - if there is no such item, conversation is closed, or timeout is reached.

poke

public void poke(java.lang.String item,
                 byte[] value)
          throws DDEException
Perform synchronous poke transaction with default timeout.

Parameters:
item - name of the item to update
value - new item value
Throws:
DDEException - if there is no such item, conversation is closed, or timeout is reached.

pokeAsync

public void pokeAsync(java.lang.String item,
                      byte[] value,
                      java.lang.String tid)
               throws DDEException
Perform asynchronous poke transaction.

Parameters:
item - name of the item to update
value - new item value
tid - transaction identification
Throws:
DDEException - if conversation is closed.

pokeAsync

public void pokeAsync(java.lang.String item,
                      byte[] value)
               throws DDEException
Perform asynchronous poke transaction. Equivalent to pokeAsync(item, value, "POKE_"+item).

Parameters:
item - name of the item to update
value - new item value
Throws:
DDEException - if conversation is closed.

startAdvice

public void startAdvice(java.lang.String item,
                        int timeout)
                 throws DDEException
Perform start advice transaction.

Parameters:
item - name of the item we want to subscribe
timeout - timeout in miliseconds
Throws:
DDEException - if there is no such item, conversation is closed, or timeout is reached.

startAdvice

public void startAdvice(java.lang.String item)
                 throws DDEException
Perform start advice transaction with default timeout.

Parameters:
item - name of the item we want to subscribe
Throws:
DDEException - if there is no such item, conversation is closed, or timeout is reached.

stopAdvice

public void stopAdvice(java.lang.String item,
                       int timeout)
                throws DDEException
Perform stop advice transaction.

Parameters:
item - name of the item we want to unsubscribe
timeout - tiemout in miliseconds
Throws:
DDEException - if there is no such item, conversation is closed, or timeout is reached.

stopAdvice

public void stopAdvice(java.lang.String item)
                throws DDEException
Perform stop advice transaction with default timeout.

Parameters:
item - name of the item we want to unsubscribe
Throws:
DDEException - if there is no such item, conversation is closed, or timeout is reached.

close

public void close()
           throws DDEException
Close this conversation with DDE server.

Throws:
DDEException

getService

public java.lang.String getService()
Get service name of the conversation.

Returns:
service name of the conversation

getTopic

public java.lang.String getTopic()
Get topic name of the conversation.

Returns:
topic name of the conversation.

setDefaultTimeout

public void setDefaultTimeout(int timeout)
Set default timeout for all synchronous transactions in this conversation.

Parameters:
timeout - timeout in miliseconds.