-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,191 additions
and
785 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
[workspace] | ||
members = ["core", "node", "rpc", "derive"] | ||
members = ["core", "transport", "node", "rpc", "derive"] | ||
|
||
resolver = "2" | ||
|
||
[workspace.dependencies] | ||
rings-core = { version = "0.2.7", path = "core", default-features = false } | ||
rings-derive = { version = "0.2.7", path = "derive", default-features = false } | ||
rings-rpc = { version = "0.2.7", path = "rpc", default-features = false } | ||
wasm-bindgen = { version = "0.2.84" } | ||
rings-core = { version = "0.3.0", path = "core", default-features = false } | ||
rings-derive = { version = "0.3.0", path = "derive", default-features = false } | ||
rings-rpc = { version = "0.3.0", path = "rpc", default-features = false } | ||
rings-transport = { version = "0.3.0", path = "transport" } | ||
wasm-bindgen = { version = "0.2.87" } | ||
wasm-bindgen-macro-support = { version = "0.2.84" } |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "rings-core" | ||
version = "0.2.7" | ||
version = "0.3.0" | ||
edition = "2021" | ||
authors = ["RND <[email protected]>"] | ||
description = "Chord DHT implementation with ICE" | ||
|
@@ -25,8 +25,9 @@ std = [ | |
"uuid/v4", | ||
"uuid/serde", | ||
"rings-derive/default", | ||
"rings-transport/native-webrtc", | ||
] | ||
dummy = ["std", "lazy_static", "tokio"] | ||
dummy = ["std", "lazy_static", "tokio", "rings-transport/dummy"] | ||
wasm = [ | ||
"web-sys", | ||
"wasm-bindgen", | ||
|
@@ -40,6 +41,7 @@ wasm = [ | |
"uuid/v4", | ||
"uuid/serde", | ||
"rings-derive/wasm", | ||
"rings-transport/web-sys-webrtc", | ||
] | ||
browser_chrome_test = ["wasm"] | ||
|
||
|
@@ -69,6 +71,7 @@ num-bigint = "0.4.3" | |
rand = { version = "0.8.5", features = ["getrandom"] } | ||
rand_core = { version = "0.6.3", features = ["getrandom"] } | ||
rand_hc = "0.3.1" | ||
rings-transport = { workspace = true } | ||
serde = { version = "1.0.130", features = ["derive"] } | ||
serde_json = { version = "1.0.70" } | ||
sha1 = "0.10.1" | ||
|
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
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
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
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
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
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
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
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
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
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,35 @@ | ||
use async_trait::async_trait; | ||
use rings_transport::core::callback::Callback; | ||
|
||
use crate::channels::Channel; | ||
use crate::error::Error; | ||
use crate::error::Result; | ||
use crate::types::channel::Channel as ChannelTrait; | ||
use crate::types::channel::TransportEvent; | ||
|
||
type TransportEventSender = <Channel<TransportEvent> as ChannelTrait<TransportEvent>>::Sender; | ||
|
||
pub struct SwarmCallback { | ||
transport_event_sender: TransportEventSender, | ||
} | ||
|
||
impl SwarmCallback { | ||
pub fn new(transport_event_sender: TransportEventSender) -> Self { | ||
Self { | ||
transport_event_sender, | ||
} | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl Callback for SwarmCallback { | ||
type Error = Error; | ||
|
||
async fn on_message(&self, cid: &str, msg: &[u8]) -> Result<()> { | ||
Channel::send( | ||
&self.transport_event_sender, | ||
TransportEvent::DataChannelMessage(msg.into()), | ||
) | ||
.await | ||
} | ||
} |
Oops, something went wrong.