SuperSocket get connected and disconnected events sessions

Keywords: connection events, disconnect events, OnSessionStarted, OnSessionClosed, NewSessionConnected, sessionClosed

AppSession virtual method OnSessionStarted () and OnSessionClosed (CloseReason reason)

 

You can override base class virtual method OnSessionStarted () and OnSessionClosed (CloseReason reason) for performing logic operations upon a number of connecting and disconnecting the session:

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

    }

}

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11126804.html