示例#1
0
    public async void OnLoginClicked()
    {
        string username = usernameInputField.text;

        if (!LCUtils.IsValidString(username))
        {
            LCUtils.ShowToast(this, "Please input valid username.");
            return;
        }
        string password = passwordInputField.text;

        if (!LCUtils.IsValidString(password))
        {
            LCUtils.ShowToast(this, "Please input valid password.");
            return;
        }

        try {
            LCUser user = await LCManager.Instance.Login(username, password);

            LCUtils.SaveUser(user);
            string nickname = user.GetNickname();
            if (string.IsNullOrEmpty(nickname))
            {
                SendMessageUpwards("ShowNameMenu", SendMessageOptions.RequireReceiver);
            }
            else
            {
                SendMessageUpwards("ShowLCMainMenu", SendMessageOptions.RequireReceiver);
            }
        } catch (LCException e) {
            LCUtils.ShowToast(this, e);
        }
    }
示例#2
0
    public async void OnLoginAnoymouslyClicked()
    {
        try {
            LCUser user = await LCUser.LoginAnonymously();

            LCUtils.SaveUser(user);
            SendMessageUpwards("ShowNameMenu", SendMessageOptions.RequireReceiver);
        } catch (LCException e) {
            LCUtils.ShowToast(this, e);
        }
    }
    public async void Decline()
    {
        try {
            await LCFriendship.DeclineRequest(request);

            SendMessageUpwards("Reload", SendMessageOptions.RequireReceiver);
        } catch (LCException e) {
            LCUtils.LogException(e);
            throw e;
        }
    }
示例#4
0
    public override async void Show()
    {
        base.Show();
        try {
            LCUser user = await LCUser.GetCurrent();

            nameText.text = user.GetNickname();
        } catch (LCException e) {
            LCUtils.LogException(e);
        }
    }
示例#5
0
    public async void Logout()
    {
        try {
            await LCManager.Instance.Logout();

            SendMessageUpwards("ShowTitleScreen", SendMessageOptions.RequireReceiver);
        } catch (LCException e) {
            // TODO Toast
            LCUtils.ShowToast(this, e);
        }
    }
示例#6
0
    public async Task <LCUser> Login(string token)
    {
        try {
            User = await LCUser.BecomeWithSessionToken(token);

            IMClient = new LCIMClient(User);
            await IMClient.Open();

            return(User);
        } catch (LCException e) {
            LCUtils.LogException(e);
            throw e;
        }
    }
示例#7
0
    public async Task <LCUser> Login(string username, string password)
    {
        try {
            User = await LCUser.Login(username, password);

            IMClient = new LCIMClient(User);
            await IMClient.Open();

            return(User);
        } catch (LCException e) {
            LCUtils.LogException(e);
            throw e;
        }
    }
示例#8
0
    public async Task Logout()
    {
        try {
            await LCUser.Logout();

            LCUtils.RemoveLocalUser();
            await IMClient.Close();

            User     = null;
            IMClient = null;
        } catch (LCException e) {
            LCUtils.LogException(e);
        }
    }
示例#9
0
    public async void Send()
    {
        string content = inputField.text;

        if (string.IsNullOrEmpty(content))
        {
            return;
        }

        try {
            LCIMTextMessage message = new LCIMTextMessage(content);
            await conversation.Send(message);

            AddMessage(message);
        } catch (LCException e) {
            LCUtils.LogException(e);
        }
    }
示例#10
0
    public async Task <LCUser> Register(string username, string password)
    {
        try {
            LCUser user = new LCUser {
                Username = username,
                Password = password
            };
            await user.SignUp();

            IMClient = new LCIMClient(user);
            await IMClient.Open();

            return(user);
        } catch (LCException e) {
            LCUtils.LogException(e);
            throw e;
        }
    }
示例#11
0
    public async void Send()
    {
        string content = inputField.text;

        if (string.IsNullOrEmpty(content))
        {
            return;
        }

        try {
            LCIMTextMessage  message      = new LCIMTextMessage(content);
            LCIMConversation conversation = await LCManager.Instance.IMClient.GetConversation(WordConversationId);

            await conversation.Send(message);

            AddMessage(message);
        } catch (LCException e) {
            LCUtils.LogException(e);
        }
    }
示例#12
0
    public async void OnOKClicked()
    {
        string nickname = nicknameInputField.text;

        if (!LCUtils.IsValidString(nickname))
        {
            LCUtils.ShowToast(this, "Please input nickname");
            return;
        }

        try {
            LCUser user = await LCUser.GetCurrent();

            user.SetNickname(nickname);
            await user.Save();

            SendMessageUpwards("BackToLCMainMenu", SendMessageOptions.RequireReceiver);
        } catch (LCException e) {
            LCUtils.LogException(e);
            LCUtils.ShowToast(this, e);
        }
    }
示例#13
0
    public async void OnRegisterClicked()
    {
        string username = usernameInputField.text;

        if (!LCUtils.IsValidString(username))
        {
            LCUtils.ShowToast(this, "Please input username.");
            return;
        }
        string password = passwordInputField.text;

        if (!LCUtils.IsValidString(password))
        {
            LCUtils.ShowToast(this, "Please input password.");
            return;
        }
        string confirmPassword = confirmPasswordInputField.text;

        if (!LCUtils.IsValidString(confirmPassword))
        {
            LCUtils.ShowToast(this, "Please retype password.");
            return;
        }
        if (password != confirmPassword)
        {
            LCUtils.ShowToast(this, "Password not match.");
            return;
        }

        try {
            await LCManager.Instance.Register(username, password);

            LCUtils.ShowToast(this, "注册成功");
            SendMessageUpwards("ShowNameMenu", SendMessageOptions.RequireReceiver);
        } catch (LCException e) {
            LCUtils.ShowToast(this, e);
        }
    }