aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock250
-rw-r--r--client-native-gui/Cargo.toml2
-rw-r--r--client-native-gui/src/main.rs162
3 files changed, 408 insertions, 6 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 6168976..45427dd 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -266,6 +266,107 @@ dependencies = [
]
[[package]]
+name = "async-channel"
+version = "1.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e14485364214912d3b19cc3435dde4df66065127f05fa0d75c712f36f12c2f28"
+dependencies = [
+ "concurrent-queue",
+ "event-listener",
+ "futures-core",
+]
+
+[[package]]
+name = "async-executor"
+version = "1.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965"
+dependencies = [
+ "async-task",
+ "concurrent-queue",
+ "fastrand",
+ "futures-lite",
+ "once_cell",
+ "slab",
+]
+
+[[package]]
+name = "async-global-executor"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0da5b41ee986eed3f524c380e6d64965aea573882a8907682ad100f7859305ca"
+dependencies = [
+ "async-channel",
+ "async-executor",
+ "async-io",
+ "async-lock",
+ "blocking",
+ "futures-lite",
+ "once_cell",
+]
+
+[[package]]
+name = "async-io"
+version = "1.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "83e21f3a490c72b3b0cf44962180e60045de2925d8dff97918f7ee43c8f637c7"
+dependencies = [
+ "autocfg",
+ "concurrent-queue",
+ "futures-lite",
+ "libc 0.2.132",
+ "log",
+ "once_cell",
+ "parking",
+ "polling",
+ "slab",
+ "socket2",
+ "waker-fn",
+ "winapi",
+]
+
+[[package]]
+name = "async-lock"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e97a171d191782fba31bb902b14ad94e24a68145032b7eedf871ab0bc0d077b6"
+dependencies = [
+ "event-listener",
+]
+
+[[package]]
+name = "async-std"
+version = "1.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d"
+dependencies = [
+ "async-channel",
+ "async-global-executor",
+ "async-io",
+ "async-lock",
+ "crossbeam-utils",
+ "futures-channel",
+ "futures-core",
+ "futures-io",
+ "futures-lite",
+ "gloo-timers",
+ "kv-log-macro",
+ "log",
+ "memchr",
+ "once_cell",
+ "pin-project-lite",
+ "pin-utils",
+ "slab",
+ "wasm-bindgen-futures",
+]
+
+[[package]]
+name = "async-task"
+version = "4.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524"
+
+[[package]]
name = "async-trait"
version = "0.1.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -379,6 +480,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae"
[[package]]
+name = "blocking"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc"
+dependencies = [
+ "async-channel",
+ "async-task",
+ "atomic-waker",
+ "fastrand",
+ "futures-lite",
+ "once_cell",
+]
+
+[[package]]
name = "buf_redux"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -427,6 +542,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db"
[[package]]
+name = "cache-padded"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"
+
+[[package]]
name = "calloop"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -627,6 +748,15 @@ dependencies = [
]
[[package]]
+name = "concurrent-queue"
+version = "1.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c"
+dependencies = [
+ "cache-padded",
+]
+
+[[package]]
name = "console"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -739,6 +869,15 @@ dependencies = [
]
[[package]]
+name = "crossbeam-utils"
+version = "0.8.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
name = "crossfont"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -805,6 +944,16 @@ dependencies = [
]
[[package]]
+name = "ctor"
+version = "0.1.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cdffe87e1d521a10f9696f833fe502293ea446d7f256c06128293a4119bdf4cb"
+dependencies = [
+ "quote",
+ "syn",
+]
+
+[[package]]
name = "ctr"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1213,6 +1362,12 @@ dependencies = [
]
[[package]]
+name = "event-listener"
+version = "2.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
+
+[[package]]
name = "expat-sys"
version = "2.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1357,6 +1512,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf"
[[package]]
+name = "futures-io"
+version = "0.3.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68"
+
+[[package]]
+name = "futures-lite"
+version = "1.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48"
+dependencies = [
+ "fastrand",
+ "futures-core",
+ "futures-io",
+ "memchr",
+ "parking",
+ "pin-project-lite",
+ "waker-fn",
+]
+
+[[package]]
name = "futures-macro"
version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1486,6 +1662,18 @@ dependencies = [
]
[[package]]
+name = "gloo-timers"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5fb7d06c1c8cc2a29bee7ec961009a0b2caa0793ee4900c2ffb348734ba1c8f9"
+dependencies = [
+ "futures-channel",
+ "futures-core",
+ "js-sys",
+ "wasm-bindgen",
+]
+
+[[package]]
name = "glow"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1877,11 +2065,13 @@ dependencies = [
name = "keks-meet"
version = "0.1.0"
dependencies = [
+ "async-std",
"client-native-lib",
"eframe",
"egui",
"env_logger",
"log",
+ "tokio",
]
[[package]]
@@ -1906,6 +2096,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
[[package]]
+name = "kv-log-macro"
+version = "1.0.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f"
+dependencies = [
+ "log",
+]
+
+[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1967,6 +2166,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if",
+ "value-bag",
]
[[package]]
@@ -2396,6 +2596,12 @@ dependencies = [
]
[[package]]
+name = "parking"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72"
+
+[[package]]
name = "parking_lot"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2503,6 +2709,20 @@ dependencies = [
]
[[package]]
+name = "polling"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "899b00b9c8ab553c743b3e11e87c5c7d423b2a2de229ba95b24a756344748011"
+dependencies = [
+ "autocfg",
+ "cfg-if",
+ "libc 0.2.132",
+ "log",
+ "wepoll-ffi",
+ "winapi",
+]
+
+[[package]]
name = "polyval"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3346,9 +3566,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
-version = "1.21.1"
+version = "1.21.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0020c875007ad96677dcc890298f4b942882c5d4eb7cc8f439fc3bf813dc9c95"
+checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099"
dependencies = [
"autocfg",
"bytes",
@@ -3356,7 +3576,6 @@ dependencies = [
"memchr",
"mio",
"num_cpus",
- "once_cell",
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
@@ -3641,6 +3860,16 @@ dependencies = [
]
[[package]]
+name = "value-bag"
+version = "1.0.0-alpha.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55"
+dependencies = [
+ "ctor",
+ "version_check",
+]
+
+[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3662,6 +3891,12 @@ dependencies = [
]
[[package]]
+name = "waker-fn"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"
+
+[[package]]
name = "walkdir"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4127,6 +4362,15 @@ dependencies = [
]
[[package]]
+name = "wepoll-ffi"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb"
+dependencies = [
+ "cc",
+]
+
+[[package]]
name = "widestring"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/client-native-gui/Cargo.toml b/client-native-gui/Cargo.toml
index b801af6..3912bc9 100644
--- a/client-native-gui/Cargo.toml
+++ b/client-native-gui/Cargo.toml
@@ -6,6 +6,8 @@ edition = "2021"
[dependencies]
client-native-lib = { path = "../client-native-lib" }
+async-std = "1.12.0"
+tokio = { version = "1.21.2", features = ["full"] }
env_logger = "0.8"
log = "0.4"
diff --git a/client-native-gui/src/main.rs b/client-native-gui/src/main.rs
index db87ed6..e376d14 100644
--- a/client-native-gui/src/main.rs
+++ b/client-native-gui/src/main.rs
@@ -1,4 +1,160 @@
-fn main() {
-
-
+#![feature(box_syntax)]
+
+use std::{
+ future::Future,
+ ops::Deref,
+ pin::Pin,
+ sync::{Arc, RwLock},
+};
+
+use async_std::task::block_on;
+use client_native_lib::{instance::Instance, peer::Peer, Config, EventHandler};
+use eframe::{egui, epaint::ahash::HashMap};
+use egui::{Ui, Visuals};
+use tokio::task::{block_in_place, JoinHandle};
+
+#[tokio::main]
+async fn main() {
+ env_logger::builder()
+ .filter_module("keks_meet", log::LevelFilter::Info)
+ .filter_module("client_native_lib", log::LevelFilter::Info)
+ .parse_env("LOG")
+ .init();
+
+ let options = eframe::NativeOptions::default();
+ eframe::run_native(
+ "keks-meet",
+ options,
+ Box::new(|cc| {
+ cc.egui_ctx.set_visuals(Visuals {
+ dark_mode: true,
+ ..Default::default()
+ });
+ Box::new(App::new())
+ }),
+ );
+}
+
+enum App {
+ Prejoin(String),
+ Joining(Option<JoinHandle<Ingame>>),
+ Ingame(Ingame),
+}
+
+impl App {
+ pub fn new() -> Self {
+ Self::Prejoin("longtest".to_string())
+ }
+}
+
+impl eframe::App for App {
+ fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
+ egui::CentralPanel::default().show(ctx, |ui| match self {
+ App::Prejoin(secret) => {
+ ui.heading("Join a meeting");
+ ui.label("Room secret:");
+ ui.text_edit_singleline(secret);
+ if ui.button("Join").clicked() {
+ let secret = secret.clone();
+ *self = Self::Joining(Some(tokio::spawn(async move {
+ Ingame::new(Config {
+ secret,
+ username: "blub".to_string(),
+ signaling_uri: "wss://meet.metamuffin.org".to_string(),
+ })
+ .await
+ })))
+ }
+ }
+ App::Joining(fut) => {
+ ui.spinner();
+ if fut.as_ref().map(|f| f.is_finished()).unwrap_or(false) {
+ *self = Self::Ingame(block_on(fut.take().unwrap()).unwrap());
+ }
+ }
+ App::Ingame(x) => x.ui(ui),
+ });
+ }
+}
+
+struct Ingame {
+ instance: Arc<Instance>,
+ handler: Arc<Handler>,
+}
+impl Ingame {
+ pub async fn new(config: Config) -> Self {
+ let handler = Arc::new(Handler::new());
+ Self {
+ instance: Instance::new(config, handler.clone()).await,
+ handler,
+ }
+ }
+
+ pub fn ui(&self, ui: &mut Ui) {
+ for (pid, peer) in self.handler.peers.read().unwrap().deref() {
+ ui.heading(format!("{}", pid));
+ }
+ }
+}
+
+struct Handler {
+ peers: std::sync::RwLock<HashMap<usize, GuiPeer>>,
+}
+
+struct GuiPeer {
+ peer: Arc<Peer>,
+}
+
+impl Handler {
+ pub fn new() -> Self {
+ Self {
+ peers: Default::default(),
+ }
+ }
+}
+
+impl EventHandler for Handler {
+ fn peer_join(
+ &self,
+ peer: std::sync::Arc<client_native_lib::peer::Peer>,
+ ) -> client_native_lib::DynFut<()> {
+ self.peers
+ .write()
+ .unwrap()
+ .insert(peer.id, GuiPeer { peer: peer.clone() });
+ Box::pin(async move {})
+ }
+
+ fn peer_leave(
+ &self,
+ peer: std::sync::Arc<client_native_lib::peer::Peer>,
+ ) -> client_native_lib::DynFut<()> {
+ self.peers.write().unwrap().remove(&peer.id);
+ Box::pin(async move {})
+ }
+
+ fn resource_added(
+ &self,
+ peer: std::sync::Arc<client_native_lib::peer::Peer>,
+ info: client_native_lib::protocol::ProvideInfo,
+ ) -> client_native_lib::DynFut<()> {
+ Box::pin(async move {})
+ }
+
+ fn resource_removed(
+ &self,
+ peer: std::sync::Arc<client_native_lib::peer::Peer>,
+ id: String,
+ ) -> client_native_lib::DynFut<()> {
+ Box::pin(async move {})
+ }
+
+ fn resource_connected(
+ &self,
+ peer: std::sync::Arc<client_native_lib::peer::Peer>,
+ resource: &client_native_lib::protocol::ProvideInfo,
+ channel: client_native_lib::peer::TransportChannel,
+ ) -> client_native_lib::DynFut<()> {
+ Box::pin(async move {})
+ }
}