pub struct Session {
pub id: Uuid,
pub heartbeat: bool,
/* private fields */
}Expand description
会话,每创建一个连接,生成一个会话
Fields§
§id: Uuid§heartbeat: boolImplementations§
Source§impl Session
impl Session
pub fn new( socket_config: Arc<SocketConfig>, session_store: Arc<RwLock<SessionStore>>, ) -> Self
Sourcepub fn get_receiver(&self) -> Receiver<MessageType>
pub fn get_receiver(&self) -> Receiver<MessageType>
注册消息处理逻辑
Trait Implementations§
Source§impl Actor for Session
impl Actor for Session
Source§type Context = WebsocketContext<Session>
type Context = WebsocketContext<Session>
Actor execution context type
Source§impl Handler<ConnectPacket> for Session
建立连接回应给客户端处理
impl Handler<ConnectPacket> for Session
建立连接回应给客户端处理
Source§impl Handler<OpenPacket> for Session
impl Handler<OpenPacket> for Session
Source§impl StreamHandler<Result<Message, ProtocolError>> for Session
impl StreamHandler<Result<Message, ProtocolError>> for Session
Source§fn handle(
&mut self,
item: Result<Message, ProtocolError>,
ctx: &mut Self::Context,
)
fn handle( &mut self, item: Result<Message, ProtocolError>, ctx: &mut Self::Context, )
收到消息后的处理
Source§fn add_stream<S>(stream: S, ctx: &mut Self::Context) -> SpawnHandlewhere
S: Stream + 'static,
Self: StreamHandler<<S as Stream>::Item>,
Self::Context: AsyncContext<Self>,
fn add_stream<S>(stream: S, ctx: &mut Self::Context) -> SpawnHandlewhere
S: Stream + 'static,
Self: StreamHandler<<S as Stream>::Item>,
Self::Context: AsyncContext<Self>,
Register a Stream to the actor context.
Auto Trait Implementations§
impl Freeze for Session
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl !UnwindSafe for Session
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more