com.jniwrapper.win32.dde
Class DdeClient

java.lang.Object
  extended by com.jniwrapper.win32.dde.DdeClient

public class DdeClient
extends java.lang.Object

This class provides functionality for establishing connection with a DDE service.


Constructor Summary
DdeClient(java.lang.String service, java.lang.String topic)
          Creates a DDE client of the specified service and topic.
 
Method Summary
 void abandonTransaction(long transactionID)
          Abandons the specified asynchronous transaction and releases all transaction resources, so that the event handler will not receive notification when the transaction is processed.
 void connect()
          Establishes connection with the service.
 void disconnect()
          Disconnects the client from the service.
 void execute(java.lang.String command, long timeout)
          Executes the specified command and waits for a confirmation response from the service.
 long executeAsync(java.lang.String command)
          Asynchronously executes the specified command.
 byte[] get(DdeItem item, long timeout)
          Makes a synchronous request to the service for data that corresponds to the specified item.
 long getAsync(DdeItem item)
          Makes an asynchronous request to the service for data that corresponds to the specified item.
 java.lang.String getServiceName()
          Returns the service name which the client is connected to.
 java.lang.String getTopicName()
          Returns the topic name which the client is connected to.
 void removeEventHandler()
          Removes the handler of the client events.
 void send(DdeItem item, byte[] data, long timeout)
          Sends data to the service and waits for a confirmation response.
 long sendAsync(DdeItem item, byte[] data)
          Asynchronously sends data to the service.
 void setEventHandler(DdeClientEventHandler eventHandler)
          Specifies the handler of the client events.
 void startAdviseLoop(DdeItem item, boolean sendData, boolean sync, long timeout)
          Begins an advise loop and waits for confirmation response from the service.
 long startAdviseLoopAsync(DdeItem item, boolean sendData, boolean sync)
          Asynchronously begins an advise loop.
 void stopAdviseLoop(DdeItem item, long timeout)
          Stops an advise loop and waits for a confirmation response from the service.
 long stopAdviseLoopAsync(DdeItem item)
          Asynchronously stops an advise loop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DdeClient

public DdeClient(java.lang.String service,
                 java.lang.String topic)
Creates a DDE client of the specified service and topic.

Parameters:
service - is the name of the service of interest. It can be the basic name (for example, MyService) or an instance-specific service name (for example, "MyService(0X0046025E)".
topic - is the name of the service's topic.
Method Detail

connect

public void connect()
             throws DdeException
Establishes connection with the service.

Throws:
DdeException

disconnect

public void disconnect()
                throws DdeException
Disconnects the client from the service.

Throws:
DdeException

getAsync

public long getAsync(DdeItem item)
              throws DdeException
Makes an asynchronous request to the service for data that corresponds to the specified item.

Parameters:
item - specifies an item name and required data format.
Returns:
an asynchronous transaction identifier.
Throws:
DdeException
See Also:
DdeItem

get

public byte[] get(DdeItem item,
                  long timeout)
           throws DdeException
Makes a synchronous request to the service for data that corresponds to the specified item.

Parameters:
item - specifies an item name and required data format.
timeout - is the maximum amount of time, in milliseconds, that the client waits for the server response.
Returns:
the data of interest.
Throws:
DdeException

sendAsync

public long sendAsync(DdeItem item,
                      byte[] data)
               throws DdeException
Asynchronously sends data to the service.

Parameters:
item - specifies an item name and data format.
data - is the data to be sent.
Returns:
an asynchronous transaction identifier.
Throws:
DdeException
See Also:
DdeItem

send

public void send(DdeItem item,
                 byte[] data,
                 long timeout)
          throws DdeException
Sends data to the service and waits for a confirmation response.

Parameters:
item - specifies an item name and data format.
data - is the data to be sent.
timeout - is the maximum amount of time, in milliseconds, that the client waits for the server's response.
Throws:
DdeException
See Also:
DdeItem

executeAsync

public long executeAsync(java.lang.String command)
                  throws DdeException
Asynchronously executes the specified command.

Parameters:
command - specifies the command to be executed.
Returns:
an asynchronous transaction identifier.
Throws:
DdeException

execute

public void execute(java.lang.String command,
                    long timeout)
             throws DdeException
Executes the specified command and waits for a confirmation response from the service.

Parameters:
command - specifies the command to be executed.
timeout - is the maximum amount of time, in milliseconds, that the client waits for the server's response.
Throws:
DdeException

startAdviseLoopAsync

public long startAdviseLoopAsync(DdeItem item,
                                 boolean sendData,
                                 boolean sync)
                          throws DdeException
Asynchronously begins an advise loop. An advise loop allows the client to get notifications when item data changes.

Parameters:
item - specifies an item name and required data format.
sendData - if true, the service will send the changed data with notification, otherwise, the service will notify the client without sending the data.
sync - if true, the service will not send the next notification until the previous one is processed by the client.
Returns:
an asynchronous transaction identifier.
Throws:
DdeException

startAdviseLoop

public void startAdviseLoop(DdeItem item,
                            boolean sendData,
                            boolean sync,
                            long timeout)
                     throws DdeException
Begins an advise loop and waits for confirmation response from the service. An advise loop allows the client to get notifications when item data changes.

Parameters:
item - specifies an item name and required data format.
sendData - if true, the service will send the changed data with notification, otherwise, the service will notify the client without sending the data.
sync - if true, the service will not send the next notification until the previous one is processed by the client.
timeout - is the maximum amount of time, in milliseconds, that the client waits for the server's response.
Throws:
DdeException

stopAdviseLoopAsync

public long stopAdviseLoopAsync(DdeItem item)
                         throws DdeException
Asynchronously stops an advise loop.

Parameters:
item - specifies an item name.
Returns:
an asynchronous transaction identifier.
Throws:
DdeException

stopAdviseLoop

public void stopAdviseLoop(DdeItem item,
                           long timeout)
                    throws DdeException
Stops an advise loop and waits for a confirmation response from the service.

Parameters:
item - specifies an item name.
timeout - is the maximum amount of time, in milliseconds, that the client waits for the server's response.
Throws:
DdeException

abandonTransaction

public void abandonTransaction(long transactionID)
                        throws DdeException
Abandons the specified asynchronous transaction and releases all transaction resources, so that the event handler will not receive notification when the transaction is processed.

Parameters:
transactionID - is a transaction identifier.
Throws:
DdeException

getServiceName

public java.lang.String getServiceName()
Returns the service name which the client is connected to.

Returns:
the service name which the client is connected to.

getTopicName

public java.lang.String getTopicName()
Returns the topic name which the client is connected to.

Returns:
the topic name which the client is connected to.

setEventHandler

public void setEventHandler(DdeClientEventHandler eventHandler)
Specifies the handler of the client events.

Parameters:
eventHandler -
See Also:
DdeClientEventHandler

removeEventHandler

public void removeEventHandler()
Removes the handler of the client events.