Skip to content

Instantly share code, notes, and snippets.

@ajay-gov
Created January 11, 2023 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajay-gov/76bc538bd306a0f77410cc6370285ffe to your computer and use it in GitHub Desktop.
Save ajay-gov/76bc538bd306a0f77410cc6370285ffe to your computer and use it in GitHub Desktop.
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