關鍵字: 連接事件, 斷開事件, 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
}
}