Exemple #1
0
        public string SendPrivateMessagePackage(PrivateMessageList privateMessageList)
        {
            if (clientModel.HasFunction(FunctionType.ChatSystem))
            {
                while (sending)
                {
                    Thread.Sleep(100);
                }

                sending   = true;
                isReceive = false;
                PrivateMessagePackage sendPackage = new PrivateMessagePackage(privateMessageList, null);
                string send = JsonSerializer.Serialize(sendPackage);
                Send(send);
                while (!isReceive)
                {
                    Thread.Sleep(100);
                }

                sending = false;
                return(receiveMessage);
            }
            else
            {
                return("Chat System offline.");
            }
        }
 public ChatModelManager()
 {
     handlers           = new List <ServerHandler>();
     chatGroupList      = ChatGroupList.GetAllGroupList();
     privateMessageList = new PrivateMessageList();
     groupMessageList   = new GroupMessageList();
     databaseOnline     = true;
     cloudDatabase      = new CloudDatabase(this);
 }
 private void Init()
 {
     FunctionTypes             = new List <FunctionType>();
     account                   = new Account();
     friendList                = new FriendList();
     chatGroupList             = ChatGroupList.GetAllGroupList();
     privateMessageList        = new PrivateMessageList();
     groupMessageList          = new GroupMessageList();
     offlinePrivateMessageList = new PrivateMessageList();
     offlineGroupMessageList   = new GroupMessageList();
 }
        public async Task DatabaseSystemOnline()
        {
            if (!databaseOnline)
            {
                databaseOnline     = true;
                privateMessageList = await cloudDatabase.GetAllPrivateMessage();

                groupMessageList = await cloudDatabase.GetAllGroupMessage();

                Console.WriteLine("Reconnect to Database System successfully.");
                foreach (var handler in handlers)
                {
                    await handler.DatabaseOnline();
                }
            }
        }
 public void SystemOnLine(FunctionType functionType)
 {
     FunctionTypes.Add(functionType);
     new Thread(() =>
     {
         if (functionType == FunctionType.ChatSystem)
         {
             if (offlinePrivateMessageList.GetSize() > 0)
             {
                 chatSystemClient.SendPrivateMessagePackage(offlinePrivateMessageList);
                 offlinePrivateMessageList = new PrivateMessageList();
             }
             if (offlineGroupMessageList.GetSize() > 0)
             {
                 chatSystemClient.SendGroupMessagePackage(offlineGroupMessageList);
                 offlineGroupMessageList = new GroupMessageList();
             }
             UpdatePage.ChatSystemUpdate();
         }
     }).Start();
 }
 public void UpdatePrivateMessageList(PrivateMessageList privateMessageList)
 {
     this.privateMessageList = privateMessageList.Copy();
     UpdatePage.ChatSystemUpdate();
 }
        public async Task <PrivateMessageList> GetPrivateMessageById(string id)
        {
            privateMessageList = await cloudDatabase.GetAllPrivateMessage();

            return(privateMessageList.GetMessageById(id).Copy());
        }
Exemple #8
0
 public PrivateMessagePackage(PrivateMessage message, string keyword) : base(InformationType.PRIVATE_MESSAGE, keyword)
 {
     SendList = new PrivateMessageList();
     SendList.AddMessage(message);
 }
Exemple #9
0
 public PrivateMessagePackage(PrivateMessageList messageList, string keyword) : base(InformationType.PRIVATE_MESSAGE, keyword)
 {
     SendList = messageList;
 }