pub trait Socket<G, S, R>where
Self: Actor + StreamHandler<Result<Message, ProtocolError>> + Handler<EventWrapper<S>> + GameServerCommunications<G, S>,
G: Actor,{
// 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§
Sourcefn hb(&self, ctx: &mut <Self as Actor>::Context)where
Self: Actor,
fn hb(&self, ctx: &mut <Self as Actor>::Context)where
Self: Actor,
Starts the websocket heartbeat
Sourcefn self_emit(ctx: &mut <Self as Actor>::Context, event: S)where
Self: Actor,
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
Sourcefn emit(ctx: &mut <Self as Actor>::Context, wrapped: &EventWrapper<S>)where
Self: Actor,
fn emit(ctx: &mut <Self as Actor>::Context, wrapped: &EventWrapper<S>)where
Self: Actor,
Serializes and sends a receiveable game event R to ctx
Sourcefn handle_receiveable(&mut self, ctx: &mut <Self as Actor>::Context, event: R)where
Self: Actor,
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
Sourcefn handle_sendable(
&mut self,
ctx: &mut <Self as Actor>::Context,
wrapped: EventWrapper<S>,
)where
Self: Actor,
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.