Skip to content

Commit cdc07b1

Browse files
authored
Merge pull request #691 from swimos/ripple
Ripple example application
2 parents 3d79e3c + 98a9a7e commit cdc07b1

File tree

11 files changed

+1489
-1
lines changed

11 files changed

+1489
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ members = [
4040
"example_apps/join_value",
4141
"example_apps/aggregations",
4242
"example_apps/time_series",
43-
"example_apps/devguide",
43+
"example_apps/devguide", "example_apps/ripple",
4444
]
4545

4646
[workspace.package]

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ host can share a single web-socket connection.
2222
[![SwimOS Form Crates.io Version][swimos-form-badge]][swimos-form-crate]
2323

2424
[swimos-badge]: https://img.shields.io/crates/v/swimos?label=swimos
25+
2526
[swimos-crate]: https://crates.io/crates/swimos
2627

2728
[swimos-form-badge]: https://img.shields.io/crates/v/swimos?label=swimos_form
29+
2830
[swimos-form-crate]: https://crates.io/crates/swimos_form
2931

3032
[swimos-client-badge]: https://img.shields.io/crates/v/swimos?label=swimos_client
33+
3134
[swimos-client-crate]: https://crates.io/crates/swimos_client
3235

3336
[Website](https://swimos.org/) | [Developer Guide](https://www.swimos.org/server/rust/developer-guide/) | [Server API Docs](https://docs.rs/swimos/latest/swimos/) | [Client API Docs](https://docs.rs/swimos_client/latest/swimos_client/)
@@ -123,6 +126,9 @@ lane will then be set to `5` and the following will be printed on the console:
123126
Received value: 5 for 'lane' on agent at URI: /examples/name.
124127
```
125128

129+
A number of example applications are available in the [example_apps](example_apps) directory which demonstrate
130+
individual features as well as more comprehensive applications.
131+
126132
## Development
127133

128134
See the [development guide](DEVELOPMENT.md).

example_apps/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ binaries for their corresponding client applications. Each directory contains de
1919
- [map_lane_persistence](map_lane_persistence): Application demonstrating Map Lanes with persistence.
2020
- [map_store](map_store): Application demonstrating Map Stores.
2121
- [map_store_persistence](map_store_persistence): Application demonstrating Map Stores with persistence.
22+
- [ripple](ripple): Real-time synchronous shared multiplayer experience.
2223
- [supply_lane](supply_lane): Application demonstrating Supply Lanes.
2324
- [time_series](time_series): Reference code for the [Time Series](https://www.swimos.org/server/rust/time-series/)
2425
guide.

example_apps/ripple/Cargo.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "ripple"
3+
version.workspace = true
4+
authors.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
homepage.workspace = true
8+
publish = false
9+
10+
[dependencies]
11+
swimos = { workspace = true, features = ["server", "agent"] }
12+
swimos_form = { workspace = true }
13+
example-util = { path = "../example_util" }
14+
swimos_utilities = { workspace = true, features = ["trigger"] }
15+
axum = { workspace = true, features = ["tokio", "http1"] }
16+
tracing = { workspace = true }
17+
tracing-subscriber = { workspace = true, features = ["env-filter"] }
18+
futures = { workspace = true }
19+
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "sync", "io-util", "fs"] }
20+
tokio-util = { workspace = true }
21+
rand = { workspace = true }
22+
chrono = { workspace = true }

example_apps/ripple/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Ripple
2+
3+
![Ripple](assets/ripple.png "Ripple")
4+
5+
Ripple is a real-time synchronous shared multiplayer experience built on the Swim platform.
6+
7+
See a hosted version of this app [here](https://ripple.swim.inc).
8+
9+
## Usage
10+
11+
Run the application using:
12+
13+
```shell
14+
$ cargo run --bin ripple
15+
```
16+
17+
Internally, this will spawn two servers: the Swim server which is running at localhost:9001 and a UI server running
18+
at http://localhost:9002. Using your browser, navigate to http://localhost:9002/index.html and randomly click
19+
on the screen to generate 'ripples'. These ripples are propagated to all users which are connected to the Swim server.
20+
You may also hold your mouse's left button down to generate a 'charge' which is denoted by a larger circle displayed on
21+
the screen.
22+
23+
This example application demonstrates a number of core Swim features:
24+
25+
- Value Lanes: To propagate the latest ripple.
26+
- Map Lanes: To propagate the current charges that are happening.
27+
- Command Lanes: For publishing new ripples and charges.
28+
- Custom Event Types: Structures and Enumerations are used by Command Lanes for mutating the state of lanes.
29+
- Event Handlers: Event Handlers are scheduled to run at random intervals to generate new ripples and prune any old
30+
charges that were not automatically removed if a user's browser suddenly closed.

example_apps/ripple/assets/ripple.png

894 KB
Loading

0 commit comments

Comments
 (0)