Skip to content

Commit a942748

Browse files
authored
ADAP-170: added fdc3 example (openfin#27)
* ADAP-170: FDC3 examples * ADAP-170: more changes in FDC3 example
1 parent 938897e commit a942748

File tree

11 files changed

+434
-45
lines changed

11 files changed

+434
-45
lines changed

RELEASENOTES-ADAPTER.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Version 7.2.1
2+
## New Features
3+
* Add support for FDC3 service
4+
15
# Version 7.1.3
26
## New Features
37
* Add support for the new notification service

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<dependency>
5959
<groupId>co.openfin</groupId>
6060
<artifactId>openfin-desktop-java-adapter</artifactId>
61-
<version>7.1.3-SNAPSHOT</version>
61+
<version>7.2.1-SNAPSHOT</version>
6262
</dependency>
6363
<dependency>
6464
<groupId>co.openfin</groupId>

src/main/java/com/openfin/desktop/demo/ChannelExample.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public ChannelExample() {
4747
* Create a provider that supports "getValue", "increment" and "incrementBy n" actions
4848
*/
4949
public void createChannelProvider() {
50-
desktopConnection.getChannel().addChannelListener(new ChannelListener() {
50+
desktopConnection.getChannel(CHANNEL_NAME).addChannelListener(new ChannelListener() {
5151
@Override
5252
public void onChannelConnect(ConnectionEvent connectionEvent) {
5353
logger.info(String.format("provider receives channel connect event from %s ", connectionEvent.getUuid()));
@@ -57,7 +57,7 @@ public void onChannelDisconnect(ConnectionEvent connectionEvent) {
5757
logger.info(String.format("provider receives channel disconnect event from %s ", connectionEvent.getUuid()));
5858
}
5959
});
60-
desktopConnection.getChannel().create(CHANNEL_NAME, new AsyncCallback<ChannelProvider>() {
60+
desktopConnection.getChannel(CHANNEL_NAME).create(new AsyncCallback<ChannelProvider>() {
6161
@Override
6262
public void onSuccess(ChannelProvider provider) {
6363
//provider created, register actions.
@@ -78,6 +78,7 @@ public JSONObject invoke(String action, JSONObject payload) {
7878
logger.info(String.format("provider processing action %s, payload=%s", action, payload.toString()));
7979
JSONObject obj = new JSONObject();
8080
obj.put("value", x.incrementAndGet());
81+
provider.publish("event", obj, null);
8182
return obj;
8283
}
8384
});
@@ -99,9 +100,18 @@ public JSONObject invoke(String action, JSONObject payload) {
99100
* Create a channel client that invokes "getValue", "increment" and "incrementBy n" actions
100101
*/
101102
public void createChannelClient() {
102-
desktopConnection.getChannel().connect(CHANNEL_NAME, new AsyncCallback<ChannelClient>() {
103+
desktopConnection.getChannel(CHANNEL_NAME).connect(CHANNEL_NAME + "Client", new AsyncCallback<ChannelClient>() {
103104
@Override
104105
public void onSuccess(ChannelClient client) {
106+
// register a channel event
107+
client.register("event", new ChannelAction() {
108+
@Override
109+
public JSONObject invoke(String action, JSONObject payload) {
110+
logger.info("channel event {}", action);
111+
return null;
112+
}
113+
});
114+
105115
//connected to provider, invoke actions provided by the provider.
106116
//get current value
107117
client.dispatch("getValue", null, new AckListener() {
@@ -148,7 +158,6 @@ public void onError(Ack ack) {
148158
}
149159
});
150160
}
151-
152161
});
153162
}
154163

@@ -164,12 +173,13 @@ public void onReady() {
164173

165174
@Override
166175
public void onClose(String error) {
176+
logger.info("onClose, value={}", error);
167177
latch.countDown();
168178
}
169179

170180
@Override
171181
public void onError(String reason) {
172-
182+
logger.info("onError, value={}", reason);
173183
}
174184

175185
@Override
@@ -194,5 +204,7 @@ public static void main(String[] args) {
194204
// TODO Auto-generated catch block
195205
e.printStackTrace();
196206
}
207+
208+
java.lang.System.exit(0);
197209
}
198210
}

0 commit comments

Comments
 (0)