Ejemplo n.º 1
0
        async Task ExecuteLoadChatRecordsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                ChatRecords.Clear();
                var chatRecords = await DataStore.GetChatRecordsAsync(true);

                ChatRecords.ReplaceRange(chatRecords);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                MessagingCenter.Send(new MessagingCenterAlert
                {
                    Title   = "Error",
                    Message = "Unable to load items.",
                    Cancel  = "OK"
                }, "message");
            }
            finally
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 2
0
        private void ConnectionLostHandler()
        {
            MessageBox.Show("与服务端的连接丢失");

            ChatUserInfos.Clear();
            ChatRecords.Clear();

            NetworkClient.Stop();

            GlobalValue.IsInRoom = false;
            MainWindow.VM.Status = "Not in room....";
        }
Ejemplo n.º 3
0
        private void RoomCloseHandler()
        {
            MessageBox.Show("当前房间已关闭");
            ChatUserInfos.Clear();
            ChatRecords.Clear();

            NetworkClient.Stop();

            if (GlobalValue.IsRoomMaster)
            {
                GlobalValue.IsRoomMaster = false;
                BroadcastServer.Stop();
                NetworkServer.Stop();
            }

            GlobalValue.IsInRoom = false;
            MainWindow.VM.Status = "Not in room....";
        }
Ejemplo n.º 4
0
        private void UserExitHandler(UserExit userExit)
        {
            if (isSelfExitRoom)
            {
                isSelfExitRoom = false;
                MessageBox.Show("你已经离开了房间");
                ChatUserInfos.Clear();
                ChatRecords.Clear();
                NetworkClient.Stop();
                GlobalValue.IsInRoom = false;
                MainWindow.VM.Status = "Not in room....";
                return;
            }

            ChatUserInfo chatUserInfo = ChatUserInfos.FirstOrDefault(c => c.UserName.Equals(userExit.UserName));

            if (chatUserInfo != null)
            {
                ChatUserInfos.Remove(chatUserInfo);
            }
        }