Example #1
0
        internal void OnDisconnect()
        {
            if (this.Disconnected)
            {
                return;
            }

            this.Disconnected = true;

            ButterflyEnvironment.GetGame().GetClientManager().UnregisterClient(Id, Username);
            SessionManagement.IncreaseDisconnection();
            Logging.WriteLine(Username + " has logged out.");


            if (!HabboinfoSaved)
            {
                HabboinfoSaved = true;
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE users SET users.last_online = '" + DateTime.Now.ToString() + "', activity_points = " + ActivityPoints + ", activity_points_lastupdate = '" + LastActivityPointsUpdate + "', credits = " + Credits + ", achievement_points = " + AchievementPoints + " WHERE id = " + Id + " ;");
                }
            }

            if (InRoom && CurrentRoom != null)
            {
                CurrentRoom.GetRoomUserManager().RemoveUserFromRoom(mClient, false, false);
            }

            if (Messenger != null)
            {
                Messenger.AppearOffline = true;
                Messenger.Destroy();
            }

            if (SubscriptionManager != null)
            {
                SubscriptionManager.Clear();
            }

            if (AvatarEffectsInventoryComponent != null)
            {
                AvatarEffectsInventoryComponent.Dispose();
            }

            if (InventoryComponent != null)
            {
                InventoryComponent.SetIdleState();
                InventoryComponent.RunDBUpdate();
            }

            this.mClient = null;
        }
Example #2
0
        public void Clear_Subscriptions_Empty()
        {
            // Arrange
            var subscription = new SubscriptionManager();

            subscription.AddSubscription <UserCreatedEvent, UserEventHandler>();

            // Act
            subscription.Clear();

            // Assert
            Assert.False(subscription.Any());
        }
Example #3
0
 /// <summary> 释放资源 </summary>
 public void Dispose()
 {
     _consumerChannel?.Dispose();
     _connection?.Dispose();
     SubscriptionManager.Clear();
 }