Example #1
0
        private void HandleOnClientDisconnected(PyTuple data)
        {
            if (data.Count != 1)
            {
                Log.Error("Received OnClientDisconnected notification with the wrong format");
                return;
            }

            PyDataType first = data[0];

            if (first is PyInteger == false)
            {
                Log.Error("Received OnClientDisconnected notification with the wrong format");
                return;
            }

            PyInteger clientID = first as PyInteger;

            // remove the client from the session list and free it's data
            if (this.ClientManager.Contains(clientID) == false)
            {
                Log.Error($"Received OnClientDisconnected notification for an unknown client {clientID}");
                return;
            }

            // get the client, search for it's common items and meta inventories and free them
            Client client = this.ClientManager.Get(clientID);

            // clear bound services for this character
            this.BoundServiceManager.OnClientDisconnected(client);

            // ensure the client is removed from other places where it shouldn't be
            client.OnClientDisconnected();

            // finally remove the client from the manager
            this.ClientManager.Remove(clientID);
        }