diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 294f5d054..5331960ca 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -19,6 +19,10 @@ serde_json = "1"
livesplit-core = { path = "../livesplit-core" }
tauri-plugin-dialog = "2"
tauri-plugin-http = "2"
+tokio = { version = "1", features = ["full"] }
+tokio-tungstenite = "0.20"
+futures-util = "0.3"
+uuid = { version = "1.0", features = ["v4"] }
[features]
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
@@ -28,4 +32,4 @@ custom-protocol = ["tauri/custom-protocol"]
lto = true
panic = "abort"
codegen-units = 1
-strip = true
+strip = true
\ No newline at end of file
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 2e7c59c8e..c0b88446c 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -2,22 +2,70 @@
use std::{
borrow::Cow,
+ collections::HashMap,
future::Future,
+ net::SocketAddr,
str::FromStr,
sync::{Arc, RwLock},
+ time::Duration,
};
+use futures_util::{SinkExt, StreamExt};
use livesplit_core::{
event::{CommandSink, Event, Result},
hotkey::KeyCode,
networking::server_protocol::Command,
HotkeyConfig, HotkeySystem, TimeSpan, TimingMethod,
};
+use serde::{Deserialize, Serialize};
use tauri::{Emitter, Manager, WebviewWindow};
+use tokio::sync::broadcast;
+use tokio_tungstenite::{accept_async, tungstenite::Message};
+use uuid::Uuid;
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(tag = "type")]
+pub enum WebSocketMessage {
+ #[serde(rename = "heartbeat")]
+ Heartbeat {
+ timestamp: u64,
+ },
+ #[serde(rename = "split")]
+ Split {
+ split_index: u32,
+ split_name: String,
+ timestamp: u64,
+ },
+ #[serde(rename = "start")]
+ Start {
+ timestamp: u64,
+ },
+ #[serde(rename = "reset")]
+ Reset {
+ timestamp: u64,
+ },
+ #[serde(rename = "pause")]
+ Pause {
+ timestamp: u64,
+ },
+ #[serde(rename = "resume")]
+ Resume {
+ timestamp: u64,
+ },
+ #[serde(rename = "undo_split")]
+ UndoSplit {
+ timestamp: u64,
+ },
+ #[serde(rename = "skip_split")]
+ SkipSplit {
+ timestamp: u64,
+ },
+}
struct State {
hotkey_system: RwLock