public void Connect(string username, string password)
        {
            if (_TcpClient.Connected == false)
            {
                _TcpClient.Connect(HOST, PORT);

                Prompt prompt = new Prompt();
                prompt.status = Status.Connected;
                this.ShowPrompt(prompt);
            }
            if (_ServerStream == null)
            {
                _ServerStream = _TcpClient.GetStream();
            }

            UserAccount usr = new UserAccount();
            usr.username = string.IsNullOrEmpty(username) ? "Guest" : username;
            usr.email = "*****@*****.**";
            string jstr = JS.Serialize<UserAccount>(usr);

            this.SendRaw(jstr);

            Thread task = new Thread(() =>
            {
                _ServerStream = _TcpClient.GetStream();

                try
                {
                    byte[] bytes = new byte[BUFFER_SIZE];
                    int bytesRead = _ServerStream.Read(bytes, 0, bytes.Length);
                    UserAccount user = JS.Deserialize<UserAccount>(bytes, bytesRead);

                    if (this.IsLoggedIn(user))
                    {
                        this._User = user;

                        Prompt prompt = new Prompt();
                        prompt.status = Status.LoggedIn;
                        this.ShowPrompt(prompt);

                        startChatListen();
                    }
                }
                catch(Exception ex)
                {
                    Prompt prompt = new Prompt();
                    prompt.status = (int)Status.LoggingError;
                    prompt.description = ex.Message;
                    this.ShowPrompt(prompt);
                }
            });
            _Threads.Add(task.GetHashCode(), task);
            task.Start();
        }
 public bool IsLoggedIn(UserAccount user = null)
 {
     if (user != null)
         return (user != null && !string.IsNullOrEmpty(user.username) && !string.IsNullOrWhiteSpace(user.username));
     else
         return (_User != null && !string.IsNullOrEmpty(_User.username) && !string.IsNullOrWhiteSpace(_User.username));
 }