|
1 | | -(ns clj-dde.core |
2 | | - [:import |
3 | | - [com.pretty_tools.dde.client DDEClientConversation] |
4 | | - [com.pretty_tools.dde.client DDEClientEventListener] |
5 | | - [com.pretty_tools.dde ClipboardFormat] |
6 | | - [com.pretty_tools.dde DDEException] |
7 | | - [com.pretty_tools.dde DDEMLException]]) |
8 | | - |
9 | | -#_(System/getProperty "java.library.path") |
10 | | - |
11 | | - |
12 | | - |
13 | | -;; implement the DDEClientEventListener interface |
14 | | - |
15 | | -(defn setEventListener |
16 | | - [conv] |
17 | | -(.setEventListener conv |
18 | | - (reify DDEClientEventListener |
19 | | - (onItemChanged [this topic item data] |
20 | | - (prn (str "Item Changed: " topic " , " item " , " data ))) |
21 | | - (onDisconnect [this] |
22 | | - (prn (str "onDisconnect() called.")))))) |
23 | | - |
24 | | - |
25 | | -(defn listen |
26 | | - [conv] |
27 | | -(.setEventListener conv |
28 | | - (reify DDEClientEventListener |
29 | | - (onItemChanged [this _ _ data] |
30 | | - (data)) |
31 | | - (onDisconnect [this] |
32 | | - (prn (str "onDisconnect() called.")))))) |
33 | | - |
34 | | - |
35 | | -(defn listen-and-print-data |
36 | | - [conv] |
37 | | -(.setEventListener conv |
38 | | - (reify DDEClientEventListener |
39 | | - (onItemChanged [this _ _ data] |
40 | | - (prn (str data))) |
41 | | - (onDisconnect [this] |
42 | | - (prn (str "onDisconnect() called.")))))) |
43 | | - |
44 | | - |
45 | | -;; instantiate a DDEClientConversation |
46 | | - |
47 | | -(defn conversation |
48 | | - [] |
49 | | - (DDEClientConversation.)) |
50 | | - |
51 | | - |
52 | | -;; Method Definitions for a DDEClientConversation. These are the 'direct' translations of java->clojure. |
53 | | -;; TODO: define more 'idiomatic, syntactic sugar' usage methods. |
54 | | - |
55 | | -(defn setTimeout |
56 | | - [conv ms] |
57 | | - (.setTimeout conv ms)) |
58 | | - |
59 | | -(defn getTimeout |
60 | | - "returns timeout length in ms" |
61 | | - [conv] |
62 | | - (.getTimeout conv)) |
63 | | - |
64 | | -(defn connect |
65 | | - [conv app topic] |
66 | | - (.connect conv app topic)) |
67 | | - |
68 | | -(defn disconnect |
69 | | - [conv] |
70 | | - (.disconnect conv)) |
71 | | - |
72 | | -(defn startAdvice |
73 | | - [conv item] |
74 | | - (.startAdvice conv item)) |
75 | | - |
76 | | -(defn stopAdvice |
77 | | - [conv item] |
78 | | - (.stopAdvice conv item)) |
79 | | - |
80 | | -(defn poke |
81 | | - [conv topic input] |
82 | | - (.poke conv topic input)) |
83 | | - |
84 | | -(defn request |
85 | | - [conv item] |
86 | | - (.request conv item)) |
87 | | - |
88 | | -(defn execute |
89 | | - [conv command] |
90 | | - (.execute conv command)) |
91 | | - |
92 | | -(defn getService |
93 | | - [conv] |
94 | | - (.getService conv)) |
95 | | - |
96 | | -(defn getTopic |
97 | | - [conv] |
98 | | - (.getTopic conv)) |
99 | | - |
100 | | -
|
| 1 | +(ns clj-dde.core |
| 2 | + [:import |
| 3 | + [com.pretty_tools.dde.client DDEClientConversation] |
| 4 | + [com.pretty_tools.dde.client DDEClientEventListener] |
| 5 | + [com.pretty_tools.dde ClipboardFormat] |
| 6 | + [com.pretty_tools.dde DDEException] |
| 7 | + [com.pretty_tools.dde DDEMLException]]) |
| 8 | + |
| 9 | +#_(System/getProperty "java.library.path") |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +;; implement the DDEClientEventListener interface |
| 14 | + |
| 15 | +(defn setEventListener |
| 16 | + [conv] |
| 17 | +(.setEventListener conv |
| 18 | + (reify DDEClientEventListener |
| 19 | + (onItemChanged [this topic item data] |
| 20 | + (prn (str "Item Changed: " topic " , " item " , " data ))) |
| 21 | + (onDisconnect [this] |
| 22 | + (prn (str "onDisconnect() called.")))))) |
| 23 | + |
| 24 | + |
| 25 | +(defn listen |
| 26 | + [conv] |
| 27 | +(.setEventListener conv |
| 28 | + (reify DDEClientEventListener |
| 29 | + (onItemChanged [this _ _ data] |
| 30 | + (data)) |
| 31 | + (onDisconnect [this] |
| 32 | + (prn (str "onDisconnect() called.")))))) |
| 33 | + |
| 34 | + |
| 35 | +(defn listen-and-print-data |
| 36 | + [conv] |
| 37 | +(.setEventListener conv |
| 38 | + (reify DDEClientEventListener |
| 39 | + (onItemChanged [this _ _ data] |
| 40 | + (prn (str data))) |
| 41 | + (onDisconnect [this] |
| 42 | + (prn (str "onDisconnect() called.")))))) |
| 43 | + |
| 44 | + |
| 45 | +;; instantiate a DDEClientConversation |
| 46 | + |
| 47 | +(defn conversation |
| 48 | + [] |
| 49 | + (DDEClientConversation.)) |
| 50 | + |
| 51 | + |
| 52 | +;; Method Definitions for a DDEClientConversation. These are the 'direct' translations of java->clojure. |
| 53 | +;; TODO: define more 'idiomatic, syntactic sugar' usage methods. |
| 54 | + |
| 55 | +(defn setTimeout |
| 56 | + [conv ms] |
| 57 | + (.setTimeout conv ms)) |
| 58 | + |
| 59 | +(defn getTimeout |
| 60 | + "returns timeout length in ms" |
| 61 | + [conv] |
| 62 | + (.getTimeout conv)) |
| 63 | + |
| 64 | +(defn connect |
| 65 | + [conv app topic] |
| 66 | + (.connect conv app topic)) |
| 67 | + |
| 68 | +(defn disconnect |
| 69 | + [conv] |
| 70 | + (.disconnect conv)) |
| 71 | + |
| 72 | +(defn startAdvice |
| 73 | + [conv item] |
| 74 | + (.startAdvice conv item)) |
| 75 | + |
| 76 | +(defn stopAdvice |
| 77 | + [conv item] |
| 78 | + (.stopAdvice conv item)) |
| 79 | + |
| 80 | +(defn poke |
| 81 | + [conv topic input] |
| 82 | + (.poke conv topic input)) |
| 83 | + |
| 84 | +(defn request |
| 85 | + [conv item] |
| 86 | + (.request conv item)) |
| 87 | + |
| 88 | +(defn execute |
| 89 | + [conv command] |
| 90 | + (.execute conv command)) |
| 91 | + |
| 92 | +(defn getService |
| 93 | + [conv] |
| 94 | + (.getService conv)) |
| 95 | + |
| 96 | +(defn getTopic |
| 97 | + [conv] |
| 98 | + (.getTopic conv)) |
0 commit comments