pub enum SendMessage {
StableResult(u64, Peer, bool, bool, Vec<u8>),
StableConnect(u64, Peer, Vec<u8>),
StableDisconnect(PeerId),
Connect(Peer),
DisConnect(Peer),
Data(u64, PeerId, Vec<u8>),
Broadcast(Broadcast, Vec<u8>),
Stream(u32, StreamType, Vec<u8>),
NetworkState(StateRequest, Sender<StateResponse>),
NetworkReboot,
NetworkStop,
OwnEvent(Vec<u8>),
}Expand description
main send message for outside channel, send from outside to chamomile.
Variants§
StableResult(u64, Peer, bool, bool, Vec<u8>)
when peer request for join, outside decide connect or not.
params is delivery_feedback_id, peer, is_connect, is_force_close, result info.
if delivery_feedback_id = 0 will not feedback.
if is_connect is true, it will add to allow directly list.
we want to build a better network, add a is_force_close.
if is_connect is false, but is_force_close if true, we
will use this peer to build our DHT for better connection.
if false, we will force close it.
In general, you can example as StableResult(0, Peer, is_ok, false, vec![]).
StableConnect(u64, Peer, Vec<u8>)
when need add a peer to stable connect, send to chamomile from outside.
if success connect, will start a stable connection, and add peer to kad, stables,
bootstraps and allowlists. if failure, will send PeerLeave to outside.
params is delivery_feedback_id, peer and custom join_info.
if delivery_feedback_id = 0 will not feedback.
StableDisconnect(PeerId)
when outside want to close a stable connectioned peer. use it force close.
params is peer_id.
Connect(Peer)
(DHT connected) when outside want to connect a peer. will try connect directly.
if connected, chamomile will add to kad and bootstrap.
params is Peer.
DisConnect(Peer)
(DHT connected) when outside donnot want to connect peer. use it to force close.
it will remove from kad and bootstrap list.
params is Peer.
Data(u64, PeerId, Vec<u8>)
when need send a data to a peer, only need know the peer_id,
the chamomile will help you send data to there.
params is delivery_feedback_id, peer_id and data_bytes.
if delivery_feedback_id = 0 will not feedback.
Broadcast(Broadcast, Vec<u8>)
when need broadcast a data to all network,
chamomile support some common algorithm, use it, donnot worry.
params is broadcast_type and data_bytes
Stream(u32, StreamType, Vec<u8>)
(Only Stable connected) Apply for build a stream between nodes.
params is u32 stream symbol, and StreamType.
NetworkState(StateRequest, Sender<StateResponse>)
Request for return the network current state info. params is request type, and return channel’s sender (async).
NetworkReboot
When receive ReceiveMessage::NetworkLost, want to reboot network, it can use.
NetworkStop
When want to close p2p network.
OwnEvent(Vec<u8>)
when want to broadcast message with same PeerId.