SuperSocket获取会话的连接和断开事件


关键字: 连接事件, 断开事件, OnSessionStarted,OnSessionClosed, NewSessionConnected, SessionClosed

AppSession 的虚方法 OnSessionStarted() 和 OnSessionClosed(CloseReason reason)

 

你可以覆盖基类的虚方法 OnSessionStarted() 和 OnSessionClosed(CloseReason reason) 用于在会话连接和断开时执行一些逻辑操作:

public class TelnetSession : AppSession<TelnetSession>

{

    protected override void OnSessionStarted()

    {

        this.Send("Welcome to SuperSocket Telnet Server");

        //add your business operations

    }

 

    protected override void OnSessionClosed(CloseReason reason)

    {

        //add your business operations

    }

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM