Beispiel #1
0
        /// <summary>
        ///   Stops the Connection, disconnects the socket and disposes used resources.
        /// </summary>
        internal void Stop()
        {
            if (!IsAlive())
                return; // Already stopped

            if (Habbo.IsLoggedIn())
            {
                Habbo.SetLoggedIn(false);
                CoreManager.ServerCore.GetStandardOut().PrintNotice("Connection stopped [" + GetIPAddressString() +
                                                                    ", " + Habbo.GetUsername() + ']');
            }
            else
            {
                CoreManager.ServerCore.GetStandardOut().PrintNotice("Connection stopped [" + GetIPAddressString() +
                                                                    ", UNKNOWN]");
            }
            try
            {
                _socket.Close();
            }
            catch (NullReferenceException)
            {
                throw;
            }
            _socket = null;
            _dataBuffer = null;
            _dataReceivedCallback = null;
        }
        private static void ProcessSSOTicket(Habbo sender, IncomingMessage message)
        {
            Habbo loggedInHabbo = CoreManager.ServerCore.GetHabboDistributor().GetHabbo(
                message.PopPrefixedString(), sender.GetConnection().GetIPAddressRaw());

            if (loggedInHabbo == null)
            {
                new MConnectionClosed
                {
                    Reason = ConnectionClosedReason.InvalidSSOTicket
                }.Send(sender);

                // TODO: Is delay needed?

                sender.GetConnection().Disconnect(); // Invalid SSO Ticket
            }
            else
            {
                // If this Habbo is already connected...
                if (loggedInHabbo.IsLoggedIn())
                {
                    // Disconnect them.
                    new MConnectionClosed
                    {
                        Reason = ConnectionClosedReason.ConcurrentLogin
                    }.Send(loggedInHabbo);
                    loggedInHabbo.GetConnection().Disconnect();
                }
                loggedInHabbo.LoginMerge(sender);
                sender = loggedInHabbo;
                sender.SetLoggedIn(true);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Checks if a given user is friends with this user.
 /// </summary>
 /// <param name="RequireLoggedIn">If true then the user must also be online.</param>
 /// <returns>True if the user is on the friends list (and online if required), false otherwise.</returns>
 public bool IsFriendsWith(Habbo User, bool RequireLoggedIn)
 {
     if (!this.fFriends.ContainsKey(User.GetID()))
     {
         return(false);
     }
     if (RequireLoggedIn)
     {
         return(User.IsLoggedIn());
     }
     return(true);
 }