Skip to content

Commit 83b0abf

Browse files
committed
Use the latest swim core java libraries (3.10.1-SNAPSHOT) and modify server code based on the new APIs
Use the latest javascript libraries (3.10.1) for the index.html page
1 parent 013f770 commit 83b0abf

8 files changed

Lines changed: 36 additions & 41 deletions

File tree

server/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Swim unifies the traditionally disparate roles of database, message broker, job manager, and application server, into a few simple constructs.
44

5-
*Read this in other languages: [English](README.md), [简体中文](README.zh-cn.md)*
5+
*Read this in other languages: [简体中文](README.zh-cn.md)*
66

77
## Web Agents
88

@@ -26,20 +26,20 @@ Visit the [documentation](https://developer.swim.ai/concepts/lanes/) for further
2626

2727
A Swim server is loaded with a **plane**, which provides the runtime for Web Agents and routes messages to the correct lanes.
2828

29-
A plane must [declare an `AgentType` field](http://github.com/swimos/tutorial/tree/master/server/src/main/java/swim/tutorial/TutorialPlane.java#L13-L14) for each Web Agent type.
29+
A plane must [declare a `SwimRoute` field](http://github.com/swimos/tutorial/tree/master/server/src/main/java/swim/tutorial/TutorialPlane.java#L13-L14) for each Web Agent type.
3030

31-
Use the `ServerLoader` utility class to [load a plane into a Swim server](http://github.com/swimos/tutorial/tree/master/server/src/main/java/swim/tutorial/TutorialPlane.java#L18). Note that your module must [`provide` `swim.api.plane.Plane` with your custom plane class](http://github.com/swimos/tutorial/tree/master/server/src/main/java/module-info.java#L8).
31+
Use the `ServerLoader` utility class to [load the default kernel modules](http://github.com/swimos/tutorial/tree/master/server/src/main/java/swim/tutorial/TutorialPlane.java#L19).
3232

3333
Visit the [documentation](https://developer.swim.ai/concepts) for further details about these concepts.
3434

3535
## Populating a Swim Server With Your Data
3636

37-
Every Swim server can be written to and read from by external processes using the Swim API. The simplest way to utilize this API is to use a **Swim client** instance to [send commands to command lanes](http://github.com/swimos/tutorial/blob/master/server/src/main/java/swim/tutorial/DataSource.java#L40).
37+
Every Swim server can be written to and read from by external processes using the Swim API. The simplest way to utilize this API is to use a **Swim client** instance to [send commands to command lanes](http://github.com/swimos/tutorial/blob/master/server/src/main/java/swim/tutorial/DataSource.java#L42).
3838

3939
Visit the [documentation](https://developer.swim.ai/concepts) for further details about these concepts.
4040

4141
## Subscribing to Swim Server Data
4242

43-
Swim client instances use Swim **links** to pull data from a Swim lanes. Like their corresponding lanes, links have overridable callback functions that can be used to [populate UIs](http://github.com/swimos/tutorial/tree/master/ui/index.html#L111-L133).
43+
Swim client instances use Swim **links** to pull data from a Swim lanes. Like their corresponding lanes, links have overridable callback functions that can be used to [populate UIs](http://github.com/swimos/tutorial/tree/master/ui/index.html#L116-L141).
4444

4545
Visit the [documentation](https://developer.swim.ai/concepts/links/) for further details about links.

server/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ repositories {
3636
}
3737

3838
dependencies {
39-
api group: 'ai.swim', name: 'swim-loader', version: version
4039
api group: 'ai.swim', name: 'swim-server', version: version
4140
api group: 'ai.swim', name: 'swim-client', version: version
4241
}

server/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
application.version=3.9.3
1+
application.version=3.10.1-SNAPSHOT
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
open module swim.tutorial {
2-
requires transitive swim.loader;
2+
requires transitive swim.api;
3+
requires swim.server;
34
requires swim.client;
45

56
exports swim.tutorial;
6-
7-
// Allow ServerLoader to load a Swim server with a TutorialPlane
8-
provides swim.api.plane.Plane with swim.tutorial.TutorialPlane;
97
}

server/src/main/java/swim/tutorial/DataSource.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package swim.tutorial;
22

3-
import swim.api.downlink.ListDownlink;
43
import swim.api.ref.SwimRef;
54
import swim.structure.Record;
6-
import swim.structure.Value;
75

86
/**
97
* Simple wrapper around some {@code SwimRef}, e.g. a {@code SwimClient} handle,

server/src/main/java/swim/tutorial/TutorialPlane.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
package swim.tutorial;
22

3-
import java.io.IOException;
43
import swim.api.SwimRoute;
5-
import swim.api.agent.AgentType;
4+
import swim.api.agent.AgentRoute;
65
import swim.api.plane.AbstractPlane;
7-
import swim.api.server.ServerContext;
86
import swim.client.ClientRuntime;
9-
import swim.loader.ServerLoader;
7+
import swim.fabric.Fabric;
8+
import swim.kernel.Kernel;
9+
import swim.server.ServerLoader;
1010

1111
public class TutorialPlane extends AbstractPlane {
1212

1313
@SwimRoute("/unit/:id")
14-
final AgentType<UnitAgent> unitAgent = agentClass(UnitAgent.class);
14+
AgentRoute<UnitAgent> unitAgent;
1515

16-
public static void main(String[] args) throws IOException, InterruptedException {
16+
public static void main(String[] args) throws InterruptedException {
17+
final Kernel kernel = ServerLoader.loadServer();
18+
final Fabric fabric = (Fabric) kernel.getSpace("basic");
1719

18-
final ServerContext server = ServerLoader.load(TutorialPlane.class.getModule()).serverContext();
19-
server.start();
20-
System.out.println("Running TutorialPlane...");
21-
// Runs asynchronously (relative to the main thread) until termination
22-
server.run();
20+
kernel.start();
21+
System.out.println("Running Tutorial plane...");
22+
kernel.run();
2323

2424
// Send data to the above Swim server. Could (and in practice, usually will)
2525
// be done in external processes instead
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
@server {
2-
@plane("tutorial") {
3-
class: "swim.tutorial.TutorialPlane"
4-
}
5-
@http(port: 9001) {
6-
plane: "tutorial"
7-
#documentRoot: "./ui/"
8-
@websocket {
9-
serverCompressionLevel: 0# -1 = default; 0 = off; 1-9 = deflate level
10-
clientCompressionLevel: 0# -1 = default; 0 = off; 1-9 = deflate level
11-
}
12-
}
1+
tutorial: @fabric {
2+
@plane(class: "swim.tutorial.TutorialPlane")
133
}
4+
5+
@web(port: 9001) {
6+
space: "tutorial"
7+
documentRoot: "./ui/"
8+
@websocket {
9+
serverCompressionLevel: 0# -1 = default; 0 = off; 1-9 = deflate level
10+
clientCompressionLevel: 0# -1 = default; 0 = off; 1-9 = deflate level
11+
}
12+
}

ui/index.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>Swim Gauge</title>
4+
<title>Swim Gauge, Pie and Chart</title>
55
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, shrink-to-fit=no, viewport-fit=cover" />
66
</head>
77
<body style="display: flex; justify-content: center; align-items: center; width: 100vw; height: 100vh; margin: 0;">
88
<div id="app" style="display: flex; width: 67%; height: 67%; flex-direction: column;">
99
</div>
10-
<script src="https://cdn.swim.ai/js/3.9.0/swim-core.js"></script>
11-
<script src="https://cdn.swim.ai/js/3.9.0/swim-ui.js"></script>
12-
<script src="https://cdn.swim.ai/js/3.9.0/swim-ux.js"></script>
10+
<script src="https://cdn.swimos.org/js/3.10.1/swim-core.js"></script>
11+
<script src="https://cdn.swimos.org/js/3.10.1/swim-mesh.js"></script>
12+
<script src="https://cdn.swimos.org/js/3.10.1/swim-ui.js"></script>
13+
<script src="https://cdn.swimos.org/js/3.10.1/swim-ux.js"></script>
1314
<script>
1415

1516
const app = new swim.HtmlAppView(document.getElementById("app"));
@@ -26,7 +27,7 @@
2627
/* Gauge View */
2728
const gauge = new swim.GaugeView()
2829
.startAngle(swim.Angle.rad(3 * Math.PI / 4))
29-
.deltaAngle(swim.Angle.rad(3 * Math.PI / 2))
30+
.sweepAngle(swim.Angle.rad(3 * Math.PI / 2))
3031
.dialColor("#cccccc")
3132
.meterColor("#989898")
3233
.title(new swim.TextRunView("Foo, Bar, Baz").font("20px sans-serif"))

0 commit comments

Comments
 (0)