Disconnect() public method

Logs the client out of the game client, and closes the stream
Codes: 0 => Client sends the "logout" command 1 => The login timer elapsed and the client wasnt logged in or this object was disposed, forcefully disconnected 2 => Invalid login query, or username was incorrect 3 => Incorrect Password 4 => An error occured while trying to login the client (could be database related) 5 => Cant create account, username exists already 6 => Error Creating new account in database 7 => Invalid query for account creation, or an exception was thrown while trying to create account 8 => Remote Connection closed the Stream or was un-readchable 9 => Forced server shutdown [No events called, database sessions are not updated, and EventArgs are disposed]
public Disconnect ( int code ) : void
code int /// The disconnect code. If set to 9, the OnDisconect event will not be called, the database /// will not be updated to reset everyone's session code, and the EventArgs objects will NOT /// be returned to the IO pool. You should only set to 9 for a planned server shutdown. ///
return void
Example #1
0
        /// <summary>
        /// Checks the timeout on a client connection. This method is used to detect hanging connections, and
        /// forcefully disconnects them.
        /// </summary>
        /// <param name="client"></param>
        protected void CheckTimeout(GpcmClient client)
        {
            // Setup vars
            DateTime   expireTime = client.Created.AddSeconds(Timeout);
            GpcmClient oldC;

            // Remove all processing connections that are hanging
            if (client.Status != LoginStatus.Completed && expireTime <= DateTime.Now)
            {
                try
                {
                    client.Disconnect(1);
                    Processing.TryRemove(client.ConnectionId, out oldC);
                }
                catch (Exception ex)
                {
                    // Log the error
                    L.LogError("NOTICE: [GpcmServer.CheckTimeout] Error removing client from processing queue. Generating Excpetion Log");
                    ExceptionHandler.GenerateExceptionLog(ex);
                }
            }
            else if (client.Status == LoginStatus.Completed)
            {
                Processing.TryRemove(client.ConnectionId, out oldC);
            }
        }
        /// <summary>
        /// Checks the timeout on a client connection. This method is used to detect hanging connections, and
        /// forcefully disconnects them.
        /// </summary>
        /// <param name="client"></param>
        protected void CheckTimeout(GpcmClient client)
        {
            // Setup vars
            DateTime expireTime = client.Created.AddSeconds(Timeout);
            GpcmClient oldC;

            // Remove all processing connections that are hanging
            if (client.Status != LoginStatus.Completed && expireTime <= DateTime.Now)
            {
                try
                {
                    client.Disconnect(1);
                    Processing.TryRemove(client.ConnectionId, out oldC);
                }
                catch (Exception ex)
                {
                    // Log the error
                    Program.ErrorLog.Write(
                        "NOTICE: [GpcmServer.CheckTimeout] Error removing client from processing queue. Generating Excpetion Log"
                    );
                    ExceptionHandler.GenerateExceptionLog(ex);
                }
            }
            else if (client.Status == LoginStatus.Completed)
            {
                Processing.TryRemove(client.ConnectionId, out oldC);
            }
        }