Skip to content

Commit

Permalink
add peer join result to receive
Browse files Browse the repository at this point in the history
  • Loading branch information
sunhuachuang committed Mar 13, 2020
1 parent 7055786 commit 25a049b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ pub enum GroupReceiveMessage {
/// when peer join, send from TDN to outside.
/// params is `peer_id`, `socket_addr` and peer `join_info`.
PeerJoin(PeerAddr, SocketAddr, Vec<u8>),
/// when peer get join result.
/// params is `peer_id`, `is_ok` and `result_data`.
PeerJoinResult(PeerAddr, bool, Vec<u8>),
/// when peer leave, send from TDN to outside.
/// params is `peer_id`.
PeerLeave(PeerAddr),
Expand Down
5 changes: 5 additions & 0 deletions src/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ async fn run_listen<M: GroupMessage>(
GroupReceiveMessage::PeerJoin(peer_addr, addr, data)
)).await;
},
ReceiveMessage::PeerJoinResult(peer_addr, is_ok, data) => {
out_send.send(M::new_group(
GroupReceiveMessage::PeerJoinResult(peer_addr, is_ok, data)
)).await;
},
ReceiveMessage::PeerLeave(peer_addr) => {
out_send.send(M::new_group(
GroupReceiveMessage::PeerLeave(peer_addr)
Expand Down

0 comments on commit 25a049b

Please sign in to comment.