-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update use new chamomile's message type
- Loading branch information
1 parent
88a5505
commit 010fac7
Showing
9 changed files
with
515 additions
and
324 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
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,34 @@ | ||
use async_std::task; | ||
use tdn::prelude::*; | ||
use tdn_permission::PermissionlessGroup; | ||
|
||
fn main() { | ||
task::block_on(async { | ||
let mut group = PermissionlessGroup::default(); | ||
let (peer_addr, send, out_recv) = start().await.unwrap(); | ||
println!("Example: peer id: {}", peer_addr.short_show()); | ||
|
||
while let Ok(message) = out_recv.recv().await { | ||
match message { | ||
ReceiveMessage::Group(msg) => match msg { | ||
GroupReceiveMessage::PeerJoin(peer, addr, data) => { | ||
group.join(peer, addr, data, send.clone()).await; | ||
} | ||
GroupReceiveMessage::PeerJoinResult(..) => { | ||
// | ||
} | ||
GroupReceiveMessage::PeerLeave(peer) => { | ||
group.leave(&peer); | ||
} | ||
GroupReceiveMessage::Event(peer, _data) => { | ||
println!("receive group event from {}", peer.short_show()); | ||
} | ||
GroupReceiveMessage::Stream(..) => { | ||
// | ||
} | ||
}, | ||
_ => {} | ||
} | ||
} | ||
}); | ||
} |
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,20 @@ | ||
use async_std::task; | ||
use std::path::PathBuf; | ||
use tdn::prelude::*; | ||
|
||
fn main() { | ||
task::block_on(async { | ||
// use crate root directory's config.toml | ||
let dir_path = PathBuf::from("."); | ||
let config = Config::load_with_path(dir_path).await; | ||
|
||
let (peer_addr, _send, out_recv) = start_with_config(config).await.unwrap(); | ||
println!("Example: peer id: {}", peer_addr.short_show()); | ||
|
||
while let Ok(message) = out_recv.recv().await { | ||
match message { | ||
_ => {} | ||
} | ||
} | ||
}); | ||
} |
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