Created
January 11, 2023 23:20
-
-
Save ajay-gov/76bc538bd306a0f77410cc6370285ffe 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
package swim.example; | |
import swim.client.ClientRuntime; | |
import swim.json.Json; | |
public class SwimMetaClient { | |
//FIX: Using a known swim application's HOST URI here, this needs to be replaced | |
// So replace "cellular.swim.services" with the ControlCenter's Endpoint URI | |
private static final String HOST_URI = "warps://cellular.swim.services"; | |
public static void main(String[] args) { | |
ClientRuntime sc = new ClientRuntime(); | |
sc.start(); | |
sc.downlink() | |
.hostUri(HOST_URI) | |
.nodeUri("swim:meta:mesh") | |
.laneUri("pulse") | |
.keepLinked(true) | |
.open() | |
.onEvent(value -> { | |
String json = Json.toString(value); | |
System.out.println(json); | |
long agentCount = value.get("nodeCount").longValue(0); | |
long eventRate = value.get("downlinks").get("eventRate").intValue(0) + | |
value.get("uplinks").get("eventRate").longValue(0); | |
System.out.println("Agent count: " + agentCount); | |
System.out.println("Event rate: " + eventRate); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment