Socket

Trait Socket 

Source
pub trait Socket<G, S, R>{
    // Required methods
    fn new(gs: Addr<G>) -> Self;
    fn hb(&self, ctx: &mut <Self as Actor>::Context)
       where Self: Actor;
    fn self_emit(ctx: &mut <Self as Actor>::Context, event: S)
       where Self: Actor;
    fn emit(ctx: &mut <Self as Actor>::Context, wrapped: &EventWrapper<S>)
       where Self: Actor;
    fn handle_receiveable(
        &mut self,
        ctx: &mut <Self as Actor>::Context,
        event: R,
    )
       where Self: Actor;
    fn handle_sendable(
        &mut self,
        ctx: &mut <Self as Actor>::Context,
        wrapped: EventWrapper<S>,
    )
       where Self: Actor;
}
Expand description

A generic game socket that can be implemented and extended to fit any game’s needs

Required Methods§

Source

fn new(gs: Addr<G>) -> Self

Creates and returns new instance of Socket

Source

fn hb(&self, ctx: &mut <Self as Actor>::Context)
where Self: Actor,

Starts the websocket heartbeat

Source

fn self_emit(ctx: &mut <Self as Actor>::Context, event: S)
where Self: Actor,

Wraps a receivable game event R (from self, to self) and emits it

This can be used for events such as errors that come from the socket and go to the associated client

Source

fn emit(ctx: &mut <Self as Actor>::Context, wrapped: &EventWrapper<S>)
where Self: Actor,

Serializes and sends a receiveable game event R to ctx

Source

fn handle_receiveable(&mut self, ctx: &mut <Self as Actor>::Context, event: R)
where Self: Actor,

Handles a receivable game event R sent to the Socket by the client

Source

fn handle_sendable( &mut self, ctx: &mut <Self as Actor>::Context, wrapped: EventWrapper<S>, )
where Self: Actor,

Handles a sendable game event S sent to the Socket by the game server G or another Socket

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§