From 67c56b66f3a006c30d8e6ea60f3bc2312fb2a7ee Mon Sep 17 00:00:00 2001 From: "Anthony W. Ho" Date: Tue, 28 Jan 2020 17:51:03 +0800 Subject: [PATCH 1/5] ADAP-183 WIP Channel API change --- .../openfin/desktop/demo/ChannelExample.java | 2 +- .../com/openfin/desktop/demo/FDC3Example.java | 2 +- .../openfin/desktop/demo/FxLayoutFrame.java | 2 +- .../desktop/demo/LaunchManifestDemo.java | 2 +- .../com/openfin/desktop/demo/LayoutFrame.java | 2 +- .../java/com/openfin/desktop/ChannelTest.java | 76 +++++++++++++++++-- 6 files changed, 75 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/openfin/desktop/demo/ChannelExample.java b/src/main/java/com/openfin/desktop/demo/ChannelExample.java index 5b91f65..3dfcde5 100644 --- a/src/main/java/com/openfin/desktop/demo/ChannelExample.java +++ b/src/main/java/com/openfin/desktop/demo/ChannelExample.java @@ -100,7 +100,7 @@ public JSONObject invoke(String action, JSONObject payload) { * Create a channel client that invokes "getValue", "increment" and "incrementBy n" actions */ public void createChannelClient() { - desktopConnection.getChannel(CHANNEL_NAME).connect(CHANNEL_NAME + "Client", new AsyncCallback() { + desktopConnection.getChannel(CHANNEL_NAME).connect(new AsyncCallback() { @Override public void onSuccess(ChannelClient client) { // register a channel event diff --git a/src/main/java/com/openfin/desktop/demo/FDC3Example.java b/src/main/java/com/openfin/desktop/demo/FDC3Example.java index 38d853c..2664a70 100644 --- a/src/main/java/com/openfin/desktop/demo/FDC3Example.java +++ b/src/main/java/com/openfin/desktop/demo/FDC3Example.java @@ -182,7 +182,7 @@ void launchOpenfin() throws DesktopException, DesktopIOException, IOException, I @Override public void onReady() { this.fdc3Client = FDC3Client.getInstance(this.desktopConnection); - this.fdc3Client.connect("JavaFDC3Demo", new AckListener() { + this.fdc3Client.connect(new AckListener() { @Override public void onSuccess(Ack ack) { btnLaunchRed.setEnabled(true); diff --git a/src/main/java/com/openfin/desktop/demo/FxLayoutFrame.java b/src/main/java/com/openfin/desktop/demo/FxLayoutFrame.java index 99aaa16..d2a67b6 100644 --- a/src/main/java/com/openfin/desktop/demo/FxLayoutFrame.java +++ b/src/main/java/com/openfin/desktop/demo/FxLayoutFrame.java @@ -58,7 +58,7 @@ public void run() { @Override public void onSuccess(Ack ack) { ExternalWindowObserver observer = (ExternalWindowObserver) ack.getSource(); - observer.getDesktopConnection().getChannel(LayoutServiceChannelName).connect(LayoutServiceChannelName, + observer.getDesktopConnection().getChannel(LayoutServiceChannelName).connect( new AsyncCallback() { @Override public void onSuccess(ChannelClient client) { diff --git a/src/main/java/com/openfin/desktop/demo/LaunchManifestDemo.java b/src/main/java/com/openfin/desktop/demo/LaunchManifestDemo.java index 88de4cd..7ab49e5 100644 --- a/src/main/java/com/openfin/desktop/demo/LaunchManifestDemo.java +++ b/src/main/java/com/openfin/desktop/demo/LaunchManifestDemo.java @@ -176,7 +176,7 @@ private void createExternalWindowObserver() { @Override public void onSuccess(Ack ack) { ExternalWindowObserver observer = (ExternalWindowObserver) ack.getSource(); - observer.getDesktopConnection().getChannel(LayoutServiceChannelName).connect(LayoutServiceChannelName, + observer.getDesktopConnection().getChannel(LayoutServiceChannelName).connect( new AsyncCallback() { @Override public void onSuccess(ChannelClient client) { diff --git a/src/main/java/com/openfin/desktop/demo/LayoutFrame.java b/src/main/java/com/openfin/desktop/demo/LayoutFrame.java index 14ea901..14e6a6e 100644 --- a/src/main/java/com/openfin/desktop/demo/LayoutFrame.java +++ b/src/main/java/com/openfin/desktop/demo/LayoutFrame.java @@ -113,7 +113,7 @@ public void actionPerformed(ActionEvent e) { @Override public void onSuccess(Ack ack) { ExternalWindowObserver observer = (ExternalWindowObserver) ack.getSource(); - observer.getDesktopConnection().getChannel(LayoutServiceChannelName).connect(LayoutServiceChannelName, + observer.getDesktopConnection().getChannel(LayoutServiceChannelName).connect( new AsyncCallback() { @Override public void onSuccess(ChannelClient client) { diff --git a/src/test/java/com/openfin/desktop/ChannelTest.java b/src/test/java/com/openfin/desktop/ChannelTest.java index f96a490..d53d98c 100644 --- a/src/test/java/com/openfin/desktop/ChannelTest.java +++ b/src/test/java/com/openfin/desktop/ChannelTest.java @@ -73,12 +73,11 @@ public void createChannelClient() throws Exception { desktopConnection.getChannel(channelName).create(new AsyncCallback() { @Override public void onSuccess(ChannelProvider provider) { - desktopConnection.getChannel(channelName).connect(channelName, new AsyncCallback() { + desktopConnection.getChannel(channelName).connect(new AsyncCallback() { @Override public void onSuccess(ChannelClient result) { latch.countDown(); } - }); } }); @@ -87,6 +86,71 @@ public void onSuccess(ChannelClient result) { assertEquals(0, latch.getCount()); } + + @Test + public void multipleChannelClients() throws Exception { + CountDownLatch latch1 = new CountDownLatch(1); + CountDownLatch latch2 = new CountDownLatch(1); + final String channelName = "createMultipleChannelClientTest"; + final String clientActionName = "clientAction"; + desktopConnection.getChannel(channelName).create(new AsyncCallback() { + @Override + public void onSuccess(ChannelProvider provider) { + + desktopConnection.getChannel(channelName).addChannelListener(new ChannelListener() { + + @Override + public void onChannelConnect(ConnectionEvent connectionEvent) { + JSONObject identity = new JSONObject(); + identity.put("uuid", connectionEvent.getUuid()); + identity.put("channelId", connectionEvent.getChannelId()); + identity.put("channelName", connectionEvent.getChannelName()); + identity.put("name", connectionEvent.getName()); + identity.put("endpointId", connectionEvent.getEndpointId()); + + provider.dispatch(identity, clientActionName, null, null); + } + + @Override + public void onChannelDisconnect(ConnectionEvent connectionEvent) { + } + }); + + //first channel client + desktopConnection.getChannel(channelName).connect(new AsyncCallback() { + @Override + public void onSuccess(ChannelClient client) { + client.register(clientActionName, new ChannelAction() { + @Override + public JSONObject invoke(String action, JSONObject payload) { + latch1.countDown(); + return null; + } + }); + } + }); + //second channel client + desktopConnection.getChannel(channelName).connect(new AsyncCallback() { + @Override + public void onSuccess(ChannelClient client) { + client.register(clientActionName, new ChannelAction() { + @Override + public JSONObject invoke(String action, JSONObject payload) { + latch2.countDown(); + return null; + } + }); + } + }); + } + }); + + latch1.await(10, TimeUnit.SECONDS); + latch2.await(10, TimeUnit.SECONDS); + + assertEquals(0, latch1.getCount()); + assertEquals(0, latch2.getCount()); + } @Test public void registerAction() throws Exception { @@ -129,7 +193,7 @@ public JSONObject invoke(String action, JSONObject payload) { } }); - desktopConnection.getChannel(channelName).connect(channelName, new AsyncCallback() { + desktopConnection.getChannel(channelName).connect(new AsyncCallback() { @Override public void onSuccess(ChannelClient client) { @@ -184,7 +248,7 @@ public void onChannelDisconnect(ConnectionEvent connectionEvent) { } }); - desktopConnection.getChannel(channelName).connect(channelName, new AsyncCallback() { + desktopConnection.getChannel(channelName).connect(new AsyncCallback() { @Override public void onSuccess(ChannelClient client) { @@ -229,7 +293,7 @@ public void onChannelDisconnect(ConnectionEvent connectionEvent) { } }); - desktopConnection.getChannel(channelName).connect(channelName, new AsyncCallback() { + desktopConnection.getChannel(channelName).connect(new AsyncCallback() { @Override public void onSuccess(ChannelClient client) { client.disconnect(null); @@ -275,7 +339,7 @@ public JSONObject invoke(String action, JSONObject payload) { } }); - desktopConnection.getChannel(channelName).connect(channelName, new AsyncCallback() { + desktopConnection.getChannel(channelName).connect(new AsyncCallback() { @Override public void onSuccess(ChannelClient client) { From 0587e24821246c73c5e6133dc71d91b665102a22 Mon Sep 17 00:00:00 2001 From: "Anthony W. Ho" Date: Thu, 30 Jan 2020 20:06:36 +0800 Subject: [PATCH 2/5] ADAP-183 WIP endpointId related change. --- .../com/openfin/desktop/demo/FDC3Example.java | 4 +- .../desktop/demo/LayoutServiceDemo.java | 2 +- .../java/com/openfin/desktop/ChannelTest.java | 54 ++++++++++--------- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/openfin/desktop/demo/FDC3Example.java b/src/main/java/com/openfin/desktop/demo/FDC3Example.java index 2664a70..8487517 100644 --- a/src/main/java/com/openfin/desktop/demo/FDC3Example.java +++ b/src/main/java/com/openfin/desktop/demo/FDC3Example.java @@ -166,8 +166,8 @@ protected JScrollPane layoutOutputPanel() { void launchOpenfin() throws DesktopException, DesktopIOException, IOException, InterruptedException { RuntimeConfiguration config = new RuntimeConfiguration(); -// config.setRuntimeVersion("stable"); - config.setRuntimeVersion("10.66.41.18"); + config.setRuntimeVersion("alpha"); +// config.setRuntimeVersion("10.66.41.18"); config.setAdditionalRuntimeArguments("--v=1 "); // serviceConfig = new JSONArray(); // JSONObject layout = new JSONObject(); diff --git a/src/main/java/com/openfin/desktop/demo/LayoutServiceDemo.java b/src/main/java/com/openfin/desktop/demo/LayoutServiceDemo.java index 6461c86..b22ac8a 100644 --- a/src/main/java/com/openfin/desktop/demo/LayoutServiceDemo.java +++ b/src/main/java/com/openfin/desktop/demo/LayoutServiceDemo.java @@ -159,7 +159,7 @@ void launchOpenfin() throws DesktopException, DesktopIOException, IOException, I if (rvm != null) { config.setLaunchRVMPath(rvm); } - config.setRuntimeVersion("stable"); + config.setRuntimeVersion("alpha"); config.setAdditionalRuntimeArguments("--v=1 "); serviceConfig = new JSONArray(); JSONObject layout = new JSONObject(); diff --git a/src/test/java/com/openfin/desktop/ChannelTest.java b/src/test/java/com/openfin/desktop/ChannelTest.java index d53d98c..52f5090 100644 --- a/src/test/java/com/openfin/desktop/ChannelTest.java +++ b/src/test/java/com/openfin/desktop/ChannelTest.java @@ -87,28 +87,41 @@ public void onSuccess(ChannelClient result) { assertEquals(0, latch.getCount()); } + @Ignore @Test public void multipleChannelClients() throws Exception { CountDownLatch latch1 = new CountDownLatch(1); CountDownLatch latch2 = new CountDownLatch(1); final String channelName = "createMultipleChannelClientTest"; final String clientActionName = "clientAction"; + final String providerActionName = "providerAction"; desktopConnection.getChannel(channelName).create(new AsyncCallback() { @Override public void onSuccess(ChannelProvider provider) { + provider.register(providerActionName, new ChannelAction() { + + @Override + public JSONObject invoke(String action, JSONObject payload) { + return null; + } + }); + desktopConnection.getChannel(channelName).addChannelListener(new ChannelListener() { @Override public void onChannelConnect(ConnectionEvent connectionEvent) { - JSONObject identity = new JSONObject(); - identity.put("uuid", connectionEvent.getUuid()); - identity.put("channelId", connectionEvent.getChannelId()); - identity.put("channelName", connectionEvent.getChannelName()); - identity.put("name", connectionEvent.getName()); - identity.put("endpointId", connectionEvent.getEndpointId()); - - provider.dispatch(identity, clientActionName, null, null); + if (channelName.equals(connectionEvent.getChannelName())) { + JSONObject identity = new JSONObject(); + identity.put("uuid", connectionEvent.getUuid()); + identity.put("channelId", connectionEvent.getChannelId()); + identity.put("channelName", connectionEvent.getChannelName()); + identity.put("name", connectionEvent.getName()); + identity.put("endpointId", connectionEvent.getEndpointId()); + + logger.info("invoke client action, destIdentity={}", identity.toString()); + provider.dispatch(identity, clientActionName, null, null); + } } @Override @@ -120,9 +133,12 @@ public void onChannelDisconnect(ConnectionEvent connectionEvent) { desktopConnection.getChannel(channelName).connect(new AsyncCallback() { @Override public void onSuccess(ChannelClient client) { + client.dispatch(providerActionName, new JSONObject(), null); + client.register(clientActionName, new ChannelAction() { @Override public JSONObject invoke(String action, JSONObject payload) { + logger.info("invoked client 1"); latch1.countDown(); return null; } @@ -136,6 +152,7 @@ public void onSuccess(ChannelClient client) { client.register(clientActionName, new ChannelAction() { @Override public JSONObject invoke(String action, JSONObject payload) { + logger.info("invoked client 2"); latch2.countDown(); return null; } @@ -233,23 +250,7 @@ public void publishToClient() throws Exception { desktopConnection.getChannel(channelName).create(new AsyncCallback() { @Override public void onSuccess(ChannelProvider provider) { - desktopConnection.getChannel(channelName).addChannelListener(new ChannelListener() { - @Override - public void onChannelConnect(ConnectionEvent connectionEvent) { - // once the channel is connected, invoke publish method - JSONObject payload = new JSONObject(); - payload.put("message", actionMessage); - provider.publish(actionName, payload, null); - } - - @Override - public void onChannelDisconnect(ConnectionEvent connectionEvent) { - - } - }); - desktopConnection.getChannel(channelName).connect(new AsyncCallback() { - @Override public void onSuccess(ChannelClient client) { @@ -262,8 +263,11 @@ public JSONObject invoke(String action, JSONObject payload) { return null; } }); + + JSONObject payload = new JSONObject(); + payload.put("message", actionMessage); + provider.publish(actionName, payload, null); } - }); } }); From 12960f8ada14ceed68eb9b077826e405a0f1c4a3 Mon Sep 17 00:00:00 2001 From: "Anthony W. Ho" Date: Thu, 30 Jan 2020 23:05:23 +0800 Subject: [PATCH 3/5] ADAP-183 added unit test --- .../java/com/openfin/desktop/ChannelTest.java | 65 ++++++++++++------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/src/test/java/com/openfin/desktop/ChannelTest.java b/src/test/java/com/openfin/desktop/ChannelTest.java index 52f5090..15c71c5 100644 --- a/src/test/java/com/openfin/desktop/ChannelTest.java +++ b/src/test/java/com/openfin/desktop/ChannelTest.java @@ -106,28 +106,6 @@ public JSONObject invoke(String action, JSONObject payload) { return null; } }); - - desktopConnection.getChannel(channelName).addChannelListener(new ChannelListener() { - - @Override - public void onChannelConnect(ConnectionEvent connectionEvent) { - if (channelName.equals(connectionEvent.getChannelName())) { - JSONObject identity = new JSONObject(); - identity.put("uuid", connectionEvent.getUuid()); - identity.put("channelId", connectionEvent.getChannelId()); - identity.put("channelName", connectionEvent.getChannelName()); - identity.put("name", connectionEvent.getName()); - identity.put("endpointId", connectionEvent.getEndpointId()); - - logger.info("invoke client action, destIdentity={}", identity.toString()); - provider.dispatch(identity, clientActionName, null, null); - } - } - - @Override - public void onChannelDisconnect(ConnectionEvent connectionEvent) { - } - }); //first channel client desktopConnection.getChannel(channelName).connect(new AsyncCallback() { @@ -157,6 +135,8 @@ public JSONObject invoke(String action, JSONObject payload) { return null; } }); + + provider.publish(clientActionName, new JSONObject(), null); } }); } @@ -239,6 +219,47 @@ public void onError(Ack ack) { assertEquals(0, latch.getCount()); assertEquals(initValue + 1, resultValue.get()); } + + @Test + public void invokeClientAction() throws Exception { + final String channelName = "invokeClientActionTest"; + final String providerActionName = "invokeClientAction"; + final String clientActionName = "clientAction"; + + CountDownLatch latch = new CountDownLatch(1); + desktopConnection.getChannel(channelName).create(new AsyncCallback() { + @Override + public void onSuccess(ChannelProvider provider) { + provider.register(providerActionName, new ChannelAction() { + @Override + public JSONObject invoke(String action, JSONObject payload) { + logger.info("invoke provider action, payload: {}", payload); + provider.dispatch(payload, clientActionName, new JSONObject(), null); + return null; + } + }); + + desktopConnection.getChannel(channelName).connect(new AsyncCallback() { + @Override + public void onSuccess(ChannelClient client) { + client.register(clientActionName, new ChannelAction() { + @Override + public JSONObject invoke(String action, JSONObject payload) { + latch.countDown(); + return null; + } + }); + + client.dispatch(providerActionName, client.getEndpointIdentity().toJSON(), null); + } + }); + } + }); + + latch.await(10, TimeUnit.SECONDS); + + assertEquals(0, latch.getCount()); + } @Test public void publishToClient() throws Exception { From 896a942e35baf70b9705f96009246b66f1f2b45a Mon Sep 17 00:00:00 2001 From: "Anthony W. Ho" Date: Mon, 3 Feb 2020 20:12:15 +0800 Subject: [PATCH 4/5] ADAP-183 channel api endpointId implementation and code refactory --- .../openfin/desktop/demo/ChannelExample.java | 8 +++---- .../desktop/demo/LaunchManifestDemo.java | 2 +- .../com/openfin/desktop/demo/LayoutFrame.java | 2 +- .../java/com/openfin/desktop/ChannelTest.java | 24 +++++++++---------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/openfin/desktop/demo/ChannelExample.java b/src/main/java/com/openfin/desktop/demo/ChannelExample.java index 3dfcde5..3078a34 100644 --- a/src/main/java/com/openfin/desktop/demo/ChannelExample.java +++ b/src/main/java/com/openfin/desktop/demo/ChannelExample.java @@ -65,7 +65,7 @@ public void onSuccess(ChannelProvider provider) { provider.register("getValue", new ChannelAction() { @Override - public JSONObject invoke(String action, JSONObject payload) { + public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { logger.info(String.format("provider processing action %s, payload=%s", action, payload.toString())); JSONObject obj = new JSONObject(); obj.put("value", x.get()); @@ -74,7 +74,7 @@ public JSONObject invoke(String action, JSONObject payload) { }); provider.register("increment", new ChannelAction() { @Override - public JSONObject invoke(String action, JSONObject payload) { + public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { logger.info(String.format("provider processing action %s, payload=%s", action, payload.toString())); JSONObject obj = new JSONObject(); obj.put("value", x.incrementAndGet()); @@ -84,7 +84,7 @@ public JSONObject invoke(String action, JSONObject payload) { }); provider.register("incrementBy", new ChannelAction() { @Override - public JSONObject invoke(String action, JSONObject payload) { + public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { logger.info(String.format("provider processing action %s, payload=%s", action, payload.toString())); int delta = payload.getInt("delta"); JSONObject obj = new JSONObject(); @@ -106,7 +106,7 @@ public void onSuccess(ChannelClient client) { // register a channel event client.register("event", new ChannelAction() { @Override - public JSONObject invoke(String action, JSONObject payload) { + public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { logger.info("channel event {}", action); return null; } diff --git a/src/main/java/com/openfin/desktop/demo/LaunchManifestDemo.java b/src/main/java/com/openfin/desktop/demo/LaunchManifestDemo.java index 7ab49e5..38161b1 100644 --- a/src/main/java/com/openfin/desktop/demo/LaunchManifestDemo.java +++ b/src/main/java/com/openfin/desktop/demo/LaunchManifestDemo.java @@ -184,7 +184,7 @@ public void onSuccess(ChannelClient client) { client.register("event", new ChannelAction() { @Override - public JSONObject invoke(String action, JSONObject payload) { + public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { System.out.printf("channel event " + action); return null; } diff --git a/src/main/java/com/openfin/desktop/demo/LayoutFrame.java b/src/main/java/com/openfin/desktop/demo/LayoutFrame.java index 14e6a6e..1a0f096 100644 --- a/src/main/java/com/openfin/desktop/demo/LayoutFrame.java +++ b/src/main/java/com/openfin/desktop/demo/LayoutFrame.java @@ -130,7 +130,7 @@ public void actionPerformed(ActionEvent e) { client.register("event", new ChannelAction() { @Override - public JSONObject invoke(String action, JSONObject payload) { + public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { System.out.printf("channel event " + action); return null; } diff --git a/src/test/java/com/openfin/desktop/ChannelTest.java b/src/test/java/com/openfin/desktop/ChannelTest.java index 15c71c5..51dd787 100644 --- a/src/test/java/com/openfin/desktop/ChannelTest.java +++ b/src/test/java/com/openfin/desktop/ChannelTest.java @@ -87,7 +87,7 @@ public void onSuccess(ChannelClient result) { assertEquals(0, latch.getCount()); } - @Ignore + //@Ignore @Test public void multipleChannelClients() throws Exception { CountDownLatch latch1 = new CountDownLatch(1); @@ -102,7 +102,7 @@ public void onSuccess(ChannelProvider provider) { provider.register(providerActionName, new ChannelAction() { @Override - public JSONObject invoke(String action, JSONObject payload) { + public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { return null; } }); @@ -115,7 +115,7 @@ public void onSuccess(ChannelClient client) { client.register(clientActionName, new ChannelAction() { @Override - public JSONObject invoke(String action, JSONObject payload) { + public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { logger.info("invoked client 1"); latch1.countDown(); return null; @@ -129,7 +129,7 @@ public JSONObject invoke(String action, JSONObject payload) { public void onSuccess(ChannelClient client) { client.register(clientActionName, new ChannelAction() { @Override - public JSONObject invoke(String action, JSONObject payload) { + public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { logger.info("invoked client 2"); latch2.countDown(); return null; @@ -158,7 +158,7 @@ public void registerAction() throws Exception { public void onSuccess(ChannelProvider provider) { provider.register("currentTime", new ChannelAction() { @Override - public JSONObject invoke(String action, JSONObject payload) { + public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { return payload.put("currentTime", java.lang.System.currentTimeMillis()); } }); @@ -184,7 +184,7 @@ public void invokeProviderAction() throws Exception { public void onSuccess(ChannelProvider provider) { provider.register(actionName, new ChannelAction() { @Override - public JSONObject invoke(String action, JSONObject payload) { + public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { int currentValue = payload.getInt("value"); return payload.put("value", currentValue + 1); } @@ -232,9 +232,9 @@ public void invokeClientAction() throws Exception { public void onSuccess(ChannelProvider provider) { provider.register(providerActionName, new ChannelAction() { @Override - public JSONObject invoke(String action, JSONObject payload) { + public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { logger.info("invoke provider action, payload: {}", payload); - provider.dispatch(payload, clientActionName, new JSONObject(), null); + provider.dispatch(senderIdentity, clientActionName, new JSONObject(), null); return null; } }); @@ -244,13 +244,13 @@ public JSONObject invoke(String action, JSONObject payload) { public void onSuccess(ChannelClient client) { client.register(clientActionName, new ChannelAction() { @Override - public JSONObject invoke(String action, JSONObject payload) { + public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { latch.countDown(); return null; } }); - client.dispatch(providerActionName, client.getEndpointIdentity().toJSON(), null); + client.dispatch(providerActionName, new JSONObject(), null); } }); } @@ -277,7 +277,7 @@ public void onSuccess(ChannelClient client) { client.register(actionName, new ChannelAction() { @Override - public JSONObject invoke(String action, JSONObject payload) { + public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { if (actionName.equals(action) && actionMessage.equals(payload.getString("message"))) { latch.countDown(); } @@ -358,7 +358,7 @@ public JSONObject invoke(String action, JSONObject payload, JSONObject senderId) provider.register(actionName, new ChannelAction() { @Override - public JSONObject invoke(String action, JSONObject payload) { + public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { int currentValue = payload.getInt("value"); return payload.put("value", currentValue + 1); } From aa1da265df343544b51952a267bca3fd8dfb096b Mon Sep 17 00:00:00 2001 From: "Anthony W. Ho" Date: Mon, 3 Feb 2020 20:27:19 +0800 Subject: [PATCH 5/5] ADAP-183 removed logging info --- src/test/java/com/openfin/desktop/ChannelTest.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/test/java/com/openfin/desktop/ChannelTest.java b/src/test/java/com/openfin/desktop/ChannelTest.java index 51dd787..22cb8a5 100644 --- a/src/test/java/com/openfin/desktop/ChannelTest.java +++ b/src/test/java/com/openfin/desktop/ChannelTest.java @@ -87,7 +87,7 @@ public void onSuccess(ChannelClient result) { assertEquals(0, latch.getCount()); } - //@Ignore + @Ignore @Test public void multipleChannelClients() throws Exception { CountDownLatch latch1 = new CountDownLatch(1); @@ -116,7 +116,6 @@ public void onSuccess(ChannelClient client) { client.register(clientActionName, new ChannelAction() { @Override public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { - logger.info("invoked client 1"); latch1.countDown(); return null; } @@ -130,7 +129,6 @@ public void onSuccess(ChannelClient client) { client.register(clientActionName, new ChannelAction() { @Override public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { - logger.info("invoked client 2"); latch2.countDown(); return null; } @@ -233,7 +231,6 @@ public void onSuccess(ChannelProvider provider) { provider.register(providerActionName, new ChannelAction() { @Override public JSONObject invoke(String action, JSONObject payload, JSONObject senderIdentity) { - logger.info("invoke provider action, payload: {}", payload); provider.dispatch(senderIdentity, clientActionName, new JSONObject(), null); return null; }