关键字: 连接事件, 断开事件, 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
}
}