-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from Far-Beyond-Dev/feature/dynamic-socket-ch…
…annels Perf: Implement Dynamic Channel-Based Socket Streaming for Infinite Worlds
- Loading branch information
Showing
4 changed files
with
42 additions
and
144 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use socketioxide::extract::{ SocketRef, Data }; | ||
use serde::Serialize; | ||
use serde_json::Value; | ||
use std::collections::HashMap; | ||
use uuid::Uuid; | ||
|
||
|
||
pub struct Object { | ||
uuid: Uuid, | ||
name: String, | ||
replicated: bool, | ||
} | ||
|
||
impl Object { | ||
pub fn new(name: String, replicated: bool) -> Self { | ||
Self { | ||
uuid: Uuid::new_v4(), | ||
name, // Fetch name from method params | ||
replicated, // Fetch replicated from method params | ||
} | ||
} | ||
|
||
pub fn get_uuid(&self) -> Uuid { | ||
self.uuid | ||
} | ||
pub fn send_event(&self, instigator: SocketRef, event_name: String, event_data: Value) { | ||
let _ = socketioxide::socket::Socket::within(&instigator, self.uuid.to_string()).emit(event_name, &event_data); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters