Created
September 21, 2010 05:55
-
-
Save ignat/589271 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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