pub struct ProtocolContext {
pub proto_id: ProtocolId,
/* private fields */
}
Expand description
Protocol handle context
Fields§
§proto_id: ProtocolId
Protocol id
Methods from Deref<Target = ServiceContext>§
Sourcepub async fn listen(&self, address: Multiaddr) -> Result<(), SendErrorKind>
pub async fn listen(&self, address: Multiaddr) -> Result<(), SendErrorKind>
Create a new listener
Sourcepub async fn dial(
&self,
address: Multiaddr,
target: TargetProtocol,
) -> Result<(), SendErrorKind>
pub async fn dial( &self, address: Multiaddr, target: TargetProtocol, ) -> Result<(), SendErrorKind>
Initiate a connection request to address
Sourcepub async fn disconnect(
&self,
session_id: SessionId,
) -> Result<(), SendErrorKind>
pub async fn disconnect( &self, session_id: SessionId, ) -> Result<(), SendErrorKind>
Disconnect a connection
Sourcepub async fn send_message_to(
&self,
session_id: SessionId,
proto_id: ProtocolId,
data: Bytes,
) -> Result<(), SendErrorKind>
pub async fn send_message_to( &self, session_id: SessionId, proto_id: ProtocolId, data: Bytes, ) -> Result<(), SendErrorKind>
Send message
Sourcepub async fn quick_send_message_to(
&self,
session_id: SessionId,
proto_id: ProtocolId,
data: Bytes,
) -> Result<(), SendErrorKind>
pub async fn quick_send_message_to( &self, session_id: SessionId, proto_id: ProtocolId, data: Bytes, ) -> Result<(), SendErrorKind>
Send message on quick channel
Sourcepub async fn filter_broadcast(
&self,
session_ids: TargetSession,
proto_id: ProtocolId,
data: Bytes,
) -> Result<(), SendErrorKind>
pub async fn filter_broadcast( &self, session_ids: TargetSession, proto_id: ProtocolId, data: Bytes, ) -> Result<(), SendErrorKind>
Send data to the specified protocol for the specified sessions.
Sourcepub async fn quick_filter_broadcast(
&self,
session_ids: TargetSession,
proto_id: ProtocolId,
data: Bytes,
) -> Result<(), SendErrorKind>
pub async fn quick_filter_broadcast( &self, session_ids: TargetSession, proto_id: ProtocolId, data: Bytes, ) -> Result<(), SendErrorKind>
Send data to the specified protocol for the specified sessions on quick channel.
Sourcepub async fn future_task<T>(&self, task: T) -> Result<(), SendErrorKind>
pub async fn future_task<T>(&self, task: T) -> Result<(), SendErrorKind>
Send a future task
Sourcepub async fn open_protocol(
&self,
session_id: SessionId,
proto_id: ProtocolId,
) -> Result<(), SendErrorKind>
pub async fn open_protocol( &self, session_id: SessionId, proto_id: ProtocolId, ) -> Result<(), SendErrorKind>
Try open a protocol
If the protocol has been open, do nothing
Sourcepub async fn open_protocols(
&self,
session_id: SessionId,
target: TargetProtocol,
) -> Result<(), SendErrorKind>
pub async fn open_protocols( &self, session_id: SessionId, target: TargetProtocol, ) -> Result<(), SendErrorKind>
Try open protocol
If the protocol has been open, do nothing
Sourcepub async fn close_protocol(
&self,
session_id: SessionId,
proto_id: ProtocolId,
) -> Result<(), SendErrorKind>
pub async fn close_protocol( &self, session_id: SessionId, proto_id: ProtocolId, ) -> Result<(), SendErrorKind>
Try close a protocol
If the protocol has been closed, do nothing
Sourcepub fn control(&self) -> &ServiceAsyncControl
pub fn control(&self) -> &ServiceAsyncControl
Get the internal channel sender side handle
Sourcepub async fn set_service_notify(
&self,
proto_id: ProtocolId,
interval: Duration,
token: u64,
) -> Result<(), SendErrorKind>
pub async fn set_service_notify( &self, proto_id: ProtocolId, interval: Duration, token: u64, ) -> Result<(), SendErrorKind>
Set a service notify token
Sourcepub async fn set_session_notify(
&self,
session_id: SessionId,
proto_id: ProtocolId,
interval: Duration,
token: u64,
) -> Result<(), SendErrorKind>
pub async fn set_session_notify( &self, session_id: SessionId, proto_id: ProtocolId, interval: Duration, token: u64, ) -> Result<(), SendErrorKind>
Set a session notify token
Sourcepub async fn remove_service_notify(
&self,
proto_id: ProtocolId,
token: u64,
) -> Result<(), SendErrorKind>
pub async fn remove_service_notify( &self, proto_id: ProtocolId, token: u64, ) -> Result<(), SendErrorKind>
Remove a service timer by a token
Sourcepub async fn remove_session_notify(
&self,
session_id: SessionId,
proto_id: ProtocolId,
token: u64,
) -> Result<(), SendErrorKind>
pub async fn remove_session_notify( &self, session_id: SessionId, proto_id: ProtocolId, token: u64, ) -> Result<(), SendErrorKind>
Remove a session timer by a token
Sourcepub async fn close(&self) -> Result<(), SendErrorKind>
pub async fn close(&self) -> Result<(), SendErrorKind>
Close service.
Order:
- close all listens
- try close all session’s protocol stream
- try close all session
- close service
Sourcepub async fn shutdown(&self) -> Result<(), SendErrorKind>
pub async fn shutdown(&self) -> Result<(), SendErrorKind>
Shutdown service, don’t care anything, may cause partial message loss