Exemplo n.º 1
0
        public static void Handle(ChatSession session, string[] recv)
        {
            int namespaceid = 0;

            if (!Int32.TryParse(recv[1], out namespaceid))
            {
                session.SendCommand(ChatError.MoreParameters, "LOGIN :Not enough parameters");
                session.Disconnect();
                return;
            }

            session.chatUserInfo.namespaceID = namespaceid;

            if (recv[2] == "*")
            {
                // Profile login, not handled yet!
                session.SendCommand(ChatError.MoreParameters, "LOGIN :Not handled yet!");
                session.Disconnect();
                return;
            }

            // Unique nickname login
            session.chatUserInfo.uniqueNickname = recv[3];
            //session.chatUserInfo.password = recv[4];

            session.SendCommand(ChatRPL.Login, "* 1 1");
        }
Exemplo n.º 2
0
        public void Handle(ISession session)
        {
            ChatSession chatSession = session as ChatSession;

            LoginResult respone = new LoginResult();

            respone.Token = "~";

            Guid id = ProfileCache.Instance.ParseEmailToGuid(Username);

            if (id == Guid.Empty)
            {
                respone.StatusCode = ResponeCode.NotFound;
                chatSession.Send(respone);
                chatSession.Disconnect();
                return;
            }

            ChatUserProfile profile = ProfileCache.Instance.GetUserProfile(id);

            Passhash = HashUtils.MD5(Passhash + id);

            if (profile.PassHashed != Passhash)
            {
                respone.StatusCode = ResponeCode.Unauthorized;
                chatSession.Send(respone);
                chatSession.Disconnect();
                return;
            }

            if (profile.Banned)
            {
                respone.StatusCode = ResponeCode.Forbidden;
                chatSession.Send(respone);
                chatSession.Disconnect();
                return;
            }

            respone.StatusCode = ResponeCode.OK;
            respone.Token      = chatSession.SessionID.ToString();
            chatSession.Send(respone);
            chatSession.FinalizeLogin(profile);
        }
Exemplo n.º 3
0
        public void Handle(ISession session)
        {
            ChatSession chatSession = session as ChatSession;

            RegisterResult responePacket = new RegisterResult();

            if (ProfileCache.Instance.ParseEmailToGuid(Email) != Guid.Empty)
            {
                responePacket.StatusCode = ResponeCode.Conflict;
                chatSession.Send(responePacket);
                chatSession.Disconnect();
                return;
            }

            Guid id = Guid.NewGuid();

            ChatUser user = new ChatUser()
            {
                ID          = id,
                Email       = this.Email,
                Password    = HashUtils.MD5(PassHashed + id),
                FirstName   = this.FirstName,
                LastName    = this.LastName,
                DateOfBirth = this.DoB,
                Gender      = this.Gender
            };

            bool added = user.Save();

            if (added)
            {
                responePacket.StatusCode = ResponeCode.OK;
                PacChatServer.GetServer().Logger.Info(String.Format("Account {0} has registered successfully.", user.Email));
            }
            else
            {
                responePacket.StatusCode = ResponeCode.NotFound;
            }

            chatSession.Send(responePacket);
            chatSession.Disconnect();
        }
        private void Disconnect()
        {
            //Sign off from the server
            Session.Disconnect();

            //Clear the list of users
            lstUsers.Items.Clear();

            //Unable to connect, change the controls
            btnSignIn.Text      = "Sign In";
            btnSend.Enabled     = false;
            txtUserName.Enabled = true;
        }
Exemplo n.º 5
0
        public static void Switch(ChatSession session, string[] recv)
        {
            string command = recv[0];

            switch (command)
            {
            case "USER":
                USERHandler.Handle(session, recv);
                break;

            case "NICK":
                NICKHandler.Handle(session, recv);
                break;

            case "CRYPT":
                CRYPTHandler.Handle(session, recv);
                break;

            case "USRIP":
                USRIPHandler.Handle(session, recv);
                break;

            case "QUIT":
                session.Disconnect();
                break;

            case "LOGIN":
                LOGINHandler.Handle(session, recv);
                break;

            default:
                string singleRecv = "";
                foreach (string data in recv)
                {
                    singleRecv += data;
                }

                session.ToLog("Unknown request: " + singleRecv);
                break;
            }
        }