Skip to content

Instantly share code, notes, and snippets.

@ignat
Created September 21, 2010 05:55
Show Gist options
  • Save ignat/589271 to your computer and use it in GitHub Desktop.
Save ignat/589271 to your computer and use it in GitHub Desktop.
DDEClient client;
Conversation bids = null;
client = DDEClient.getInstance();
// Add event handler
client.addDDEEventListener(new DDEEventListener() {
public void onAsyncCompleted(AsyncCompletedEvent e) {}
public void onDisconnect(DDEEvent e) {
System.out.println("Server has closed connection");
}
public void onItemChanged(ItemChangedEvent e) {
// Item has changed, print its value
System.out.println("Topic:"
+ e.getConversation().getTopic());
System.out.println("ItemName:"
+ e.getItemName());
System.out.println("ItemValue:"
+ new String(e.getItemValue()));
}
});
try {
bids = client.connect("MTA", "BID");
// Subscribe to A1 cell changes
bids.startAdvice("USDCHF");
System.out.println("Press Enter to quit");
try {
System.in.read();
} catch (java.io.IOException ignore) {}
bids.stopAdvice("USDCHF");
} catch (DDEException e) {
e.printStackTrace();
} finally {
try {bids.close();} catch (Exception e) {}
}
client.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment