Trait vapcore_network::NetworkProtocolHandler[][src]

pub trait NetworkProtocolHandler: Sync + Send {
    fn read(
        &self,
        io: &dyn NetworkContext,
        peer: &PeerId,
        packet_id: u8,
        data: &[u8]
    );
fn connected(&self, io: &dyn NetworkContext, peer: &PeerId);
fn disconnected(&self, io: &dyn NetworkContext, peer: &PeerId); fn initialize(&self, _io: &dyn NetworkContext) { ... }
fn timeout(&self, _io: &dyn NetworkContext, _timer: TimerToken) { ... } }

Network IO protocol handler. This needs to be implemented for each new subprotocol. All the handler function are called from within IO event loop. Message is the type for message data.

Required methods

fn read(
    &self,
    io: &dyn NetworkContext,
    peer: &PeerId,
    packet_id: u8,
    data: &[u8]
)
[src]

Called when new network packet received.

fn connected(&self, io: &dyn NetworkContext, peer: &PeerId)[src]

Called when new peer is connected. Only called when peer supports the same protocol.

fn disconnected(&self, io: &dyn NetworkContext, peer: &PeerId)[src]

Called when a previously connected peer disconnects.

Loading content...

Provided methods

fn initialize(&self, _io: &dyn NetworkContext)[src]

Initialize the handler

fn timeout(&self, _io: &dyn NetworkContext, _timer: TimerToken)[src]

Timer function called after a timeout created with NetworkContext::timeout.

Loading content...

Implementors

Loading content...