Beispiel #1
0
 /// <summary>
 /// 发送聊天内容
 /// </summary>
 private void RaiseSendStringHandler()
 {
     if (string.IsNullOrEmpty(ChatString))
     {
         return;
     }
     App.Current.Dispatcher.Invoke(() =>
     {
         var info = new ChatInfoModel
         {
             Message  = ChatString,
             SenderId = _id,
             Type     = ChatMessageType.String,
             Role     = ChatRoleType.Sender
         };
         ChatInfos.Add(info);
     });
     if (DotNettyServerHandler != null)
     {
         DotNettyServerHandler.SendData(new TestEvent()
         {
             code   = EventCode.Chat,
             time   = UtilHelper.GetCurrentTimeStamp(),
             msg    = "服务器推送",
             fromId = "",
             reqId  = Guid.NewGuid().ToString(),
             data   = ChatString
         });
     }
     ChatString = string.Empty;
 }
 /// <summary>
 /// 发送聊天内容
 /// </summary>
 private void RaiseSendStringHandler()
 {
     if (string.IsNullOrEmpty(ChatString))
     {
         return;
     }
     App.Current.Dispatcher.Invoke(() =>
     {
         var info = new ChatInfoModel
         {
             Message  = ChatString,
             SenderId = _id,
             Type     = ChatMessageType.String,
             Role     = ChatRoleType.Sender
         };
         ChatInfos.Add(info);
     });
     ClientEventHandler.SendData(new NettyBody()
     {
         code   = (int)NettyCodeEnum.Chat,
         time   = UtilHelper.GetCurrentTimeStamp(),
         msg    = "客户端请求",
         fromId = "",
         reqId  = Guid.NewGuid().ToString(),
         data   = ChatString
     });
     ChatString = string.Empty;
 }
Beispiel #3
0
 /// <summary>
 /// 发送聊天内容
 /// </summary>
 private void RaiseSendStringHandler()
 {
     if (string.IsNullOrEmpty(ChatString))
     {
         return;
     }
     App.Current.Dispatcher.Invoke(() =>
     {
         var info = new ChatInfoModel
         {
             Message  = ChatString,
             SenderId = _id,
             Type     = ChatMessageType.String,
             Role     = ChatRoleType.Sender
         };
         ChatInfos.Add(info);
     });
     if (DotNettyServerHandler != null)
     {
         DotNettyServerHandler.SendData(new ChatInfo()
         {
             Code   = (int)NettyCodeEnum.Chat,
             Time   = UtilHelper.GetCurrentTimeStamp(),
             ToId   = "所有客户端,实际发送时会赋值客户端地址",
             FromId = "服务端",
             ReqId  = Guid.NewGuid().ToString(),
             Data   = ChatString
         });
     }
     ChatString = string.Empty;
 }
 private void ReceiveMessage(ChatInfoModel info)
 {
     if (_id.Equals(info.SenderId))
     {
         return;
     }
     info.Role = ChatRoleType.Receiver;
     ChatInfos.Add(info);
 }
Beispiel #5
0
 /// <summary>
 /// 收到信息
 /// </summary>
 /// <param name="testEvent"></param>
 private void ReceiveMessage(TestEvent testEvent)
 {
     App.Current.Dispatcher.Invoke(() =>
     {
         ChatInfoModel info = new ChatInfoModel
         {
             Message  = testEvent.data,
             SenderId = "ddd",
             Type     = ChatMessageType.String,
             Role     = ChatRoleType.Receiver
         };
         ChatInfos.Add(info);
     });
 }
 /// <summary>
 /// 收到信息
 /// </summary>
 /// <param name="testEvent"></param>
 private void ReceiveMessage(NettyBody testEvent)
 {
     if (App.Current == null)
     {
         return;
     }
     App.Current.Dispatcher.Invoke(() =>
     {
         ChatInfoModel info = new ChatInfoModel
         {
             Message  = testEvent.data,
             SenderId = "ddd",
             Type     = ChatMessageType.String,
             Role     = ChatRoleType.Receiver
         };
         ChatInfos.Add(info);
     });
 }
Beispiel #7
0
        public List <Message> getChat(ChatInfos ci)
        {
            SalonUtilisateur s1 = null;
            SalonUtilisateur s2 = null;
            List <Message>   listTemp = new List <Message>();
            List <Message>   listTemp1 = new List <Message>();
            List <Message>   listTemp2 = new List <Message>();
            int i1 = 0, i2 = 0;

            foreach (SalonUtilisateur su in RessourcesSimon.listSalonUtilisateur)
            {
                if (su.Id == ci.IdCurrentSalon)
                {
                    s1 = su;
                }
                if (su.Id == ci.IdCurrentUtilisateur)
                {
                    s2 = su;
                }
            }

            if (s1 != null && s2 != null)
            {
                foreach (Message mess in s1.ListMessage)
                {
                    if (mess.Tag.Equals(RessourcesSimon.TAG_CHAT) && mess.Auteur.Id == ci.IdCurrentUtilisateur)
                    {
                        listTemp1.Add(mess);
                    }
                }

                foreach (Message mess in s2.ListMessage)
                {
                    if (mess.Tag.Equals(RessourcesSimon.TAG_CHAT) && mess.Auteur.Id == ci.IdCurrentSalon)
                    {
                        listTemp2.Add(mess);
                    }
                }

                while (i1 != listTemp1.Count || i2 != listTemp2.Count)
                {
                    if (i1 == listTemp1.Count)
                    {
                        ajouterMessage(listTemp, listTemp2.ElementAt(i2++));
                    }
                    else if (i2 == listTemp2.Count)
                    {
                        ajouterMessage(listTemp, listTemp1.ElementAt(i1++));
                    }
                    else
                    {
                        if (DateTime.Compare(listTemp1.ElementAt(i1).Date, listTemp2.ElementAt(i2).Date) <= 0)
                        {
                            ajouterMessage(listTemp, listTemp1.ElementAt(i1++));
                        }
                        else
                        {
                            ajouterMessage(listTemp, listTemp2.ElementAt(i2++));
                        }
                    }
                }
            }
            return(listTemp);
        }