예제 #1
0
파일: NSConvList.cs 프로젝트: zvrr/mars-1
        protected override void onFinished(ConversationListRequest request, ConversationListResponse response)
        {
            MarsEventArgs args = new MarsEventArgs();

            if (response == null)
            {
                args.Code = EventConst.FAIL;
            }
            else
            {
                args.Code = EventConst.SUCCESS;
                ObservableCollection <LocalConversation> resultList = new ObservableCollection <LocalConversation>();
                if (response.ListList != null)
                {
                    foreach (Conversation con in response.ListList)
                    {
                        LocalConversation localCon = new LocalConversation();
                        localCon.ConId     = con.Topic;
                        localCon.ConName   = con.Name;
                        localCon.ConNotice = con.Notice;
                        resultList.Add(localCon);
                    }
                }
                args.Data = resultList;
            }
            MarsPushMgr.onPush(getCmdID(), args);
        }
예제 #2
0
파일: NSConvList.cs 프로젝트: zvrr/mars-1
        protected override void onFailed(ConversationListRequest request, ConversationListResponse response)
        {
            MarsEventArgs args = new MarsEventArgs();

            args.Code = EventConst.FAIL;
            MarsPushMgr.onPush(getCmdID(), args);
        }
예제 #3
0
파일: DataCore.cs 프로젝트: zvrr/mars-1
 public void onPush(int cmdID, MarsEventArgs args)
 {
     if (cmdID == (int)CgiCmdID.CgiCmdID_PushMsg && args != null && args.Code == EventConst.SUCCESS)
     {
         ChatMsg msg = (ChatMsg)args.Data;
         if (msg != null)
         {
             addMsg(msg);
         }
     }
 }
예제 #4
0
 public void onPush(int cmdID, MarsEventArgs args)
 {
     if (cmdID == (int)CgiCmdID.CgiCmdID_ConvList && args != null && args.Code == EventConst.SUCCESS)
     {
         //成功
         hideLoading(false);
         ObservableCollection <LocalConversation> resultList = (ObservableCollection <LocalConversation>)args.Data;
         DataCore.getInstance().setConversationList(resultList);
     }
     else
     {
         //失败
         hideLoading(true);
         DataCore.getInstance().clearConversationList();
     }
 }
예제 #5
0
        public void OnPush(int cmdid, byte[] msgpayload)
        {
            MessagePush msgPush  = MessagePush.ParseFrom(msgpayload);
            ChatMsg     localMsg = new ChatMsg();

            localMsg.ConversationId = msgPush.Topic;
            localMsg.From           = msgPush.From;
            localMsg.IsComMeg       = true;
            localMsg.Message        = msgPush.Content;
            localMsg.Date           = DateTime.Now.ToString();
            MarsEventArgs args = new MarsEventArgs();

            args.Code = EventConst.SUCCESS;
            args.Data = localMsg;
            MarsPushMgr.onPush(cmdid, args);
            return;
        }
예제 #6
0
 public static void onPush(int cmdID, MarsEventArgs args)
 {
     lock (sLocker)
     {
         if (sObserverList.ContainsKey(cmdID))
         {
             List <IMarsPushObserver> list = sObserverList[cmdID];
             foreach (IMarsPushObserver obc in list)
             {
                 Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                 {
                     if (obc != null)
                     {
                         obc.onPush(cmdID, args);
                     }
                 });
             }
         }
     }
 }