|
13 | 13 | import java.awt.event.WindowEvent; |
14 | 14 | import java.io.IOException; |
15 | 15 | import java.lang.System; |
| 16 | +import java.util.List; |
16 | 17 | import java.util.UUID; |
17 | 18 |
|
18 | 19 | public class FDC3Example implements DesktopStateListener { |
@@ -220,41 +221,38 @@ private void sendTickerToReds() { |
220 | 221 | JSONObject id = new JSONObject(); |
221 | 222 | id.put("ticker", ticker.toLowerCase()); |
222 | 223 | context.setId(id); |
223 | | - fdc3Client.raiseIntent("fdc3.ViewChart", context, "fdc3-charts-red", new AsyncCallback<IntentResolution>() { |
| 224 | + fdc3Client.raiseIntent("ViewChart", context, "fdc3-charts-red", new AsyncCallback<IntentResolution>() { |
224 | 225 | @Override |
225 | 226 | public void onSuccess(IntentResolution result) { |
| 227 | + output.setText(String.format("IntentResolution source=%s, version=%s", result.getSource(), result.getVersion())); |
226 | 228 | } |
227 | 229 | }); |
228 | 230 | } |
229 | 231 |
|
230 | 232 | private void findIntent() { |
231 | | - fdc3Client.findIntent("fdc3.ViewChart", null, new AckListener() { |
232 | | - @Override |
233 | | - public void onSuccess(Ack ack) { |
234 | | - if (ack.isSuccessful()) { |
235 | | - output.setText(String.format("Intent found: %s", ack.getJsonObject().getJSONObject("data").getJSONObject("result"))); |
236 | | - } |
237 | | - } |
238 | | - @Override |
239 | | - public void onError(Ack ack) { |
240 | | - } |
| 233 | + fdc3Client.findIntent("ViewChart", null, new AsyncCallback<AppIntent>() { |
| 234 | + @Override |
| 235 | + public void onSuccess(AppIntent result) { |
| 236 | + output.setText(result.toString()); |
| 237 | + |
| 238 | + } |
241 | 239 | }); |
242 | 240 | } |
243 | 241 |
|
244 | | - private void findContextIntent() { |
245 | | - String ticker = getTicker(); |
246 | | - Context context = new Context("fdc3.instrument", ticker); |
| 242 | + private void findContextIntent() { |
| 243 | + String ticker = getTicker(); |
| 244 | + Context context = new Context("fdc3.instrument", ticker); |
247 | 245 |
|
248 | | - fdc3Client.findIntentsByContext(context, new AckListener() { |
249 | | - @Override |
250 | | - public void onSuccess(Ack ack) { |
251 | | - output.setText(String.format("Intent found: %s", ack.getJsonObject().getJSONObject("data").getJSONArray("result"))); |
252 | | - } |
253 | | - @Override |
254 | | - public void onError(Ack ack) { |
255 | | - } |
256 | | - }); |
257 | | - } |
| 246 | + fdc3Client.findIntentsByContext(context, new AsyncCallback<List<AppIntent>>() { |
| 247 | + |
| 248 | + @Override |
| 249 | + public void onSuccess(List<AppIntent> result) { |
| 250 | + for (int i=0; i<result.size(); i++) { |
| 251 | + output.setText(i + ":" + result.get(i).toString()); |
| 252 | + } |
| 253 | + } |
| 254 | + }); |
| 255 | + } |
258 | 256 |
|
259 | 257 | private void broadcast() { |
260 | 258 | String ticker = getTicker(); |
@@ -300,7 +298,7 @@ public void onError(Ack ack) { |
300 | 298 | } |
301 | 299 |
|
302 | 300 | private void addIntentListener() { |
303 | | - fdc3Client.addIntentListener("fdc3.ViewChart", new IntentListener() { |
| 301 | + fdc3Client.addIntentListener("ViewChartByJava", new IntentListener() { |
304 | 302 | @Override |
305 | 303 | public JSONObject onIntent(Context context) { |
306 | 304 | output.setText(String.format("Received Intent: %s", context.toString())); |
|
0 commit comments