Ejemplo n.º 1
0
        //ADD:
        public void SendAddGps(long identityId, ref MyGps gps)
        {
            var msg = new AddMsg();
            msg.IdentityId=identityId;
            msg.Name=gps.Name;
            msg.Description=gps.Description;
            msg.Coords=gps.Coords;
            msg.ShowOnHud=gps.ShowOnHud;
            msg.IsFinal=(gps.DiscardAt==null?true:false);

            MyMultiplayer.RaiseStaticEvent(s => MyGpsCollection.OnAddGps, msg);
        }
Ejemplo n.º 2
0
        //ADD:
        public void SendAddGps(long identityId, ref MyGps gps)
        {
            var msg = new AddMsg();

            msg.IdentityId  = identityId;
            msg.Name        = gps.Name;
            msg.Description = gps.Description;
            msg.Coords      = gps.Coords;
            msg.ShowOnHud   = gps.ShowOnHud;
            msg.IsFinal     = (gps.DiscardAt == null?true:false);

            MyMultiplayer.RaiseStaticEvent(s => MyGpsCollection.OnAddGps, msg);
        }
        //ADD:
        public void SendAddGps(long identityId, ref MyGps gps)
        {
            var msg = new AddMsg();

            msg.IdentityId  = identityId;
            msg.Name        = gps.Name;
            msg.Description = gps.Description;
            msg.Coords      = gps.Coords;
            msg.ShowOnHud   = gps.ShowOnHud;
            msg.IsFinal     = (gps.DiscardAt == null?true:false);

            Sync.Layer.SendMessageToServer(ref msg, MyTransportMessageEnum.Request);
        }
Ejemplo n.º 4
0
        void SendMsg(string str, string toUser)
        {
            SendMsgResponse smr = client.SendMsg(str, toUser);

            if (smr.BaseResponse.Ret == 0)
            {
                AddMsg msg = new AddMsg();
                msg.FromUserName = client.CurrentUser.UserName;
                msg.ToUserName   = toUser;
                msg.Content      = str;
                msg.MsgType      = MsgType.MM_DATA_TEXT;
                this.RefreshMsg(null, new TEventArgs <List <AddMsg> >(new AddMsg[] { msg }.ToList()));
                this.tss_Msg.Text = "发送成功!";
                this.txt_msg.Text = "";
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 推送新增物流订单消息
        /// </summary>
        /// <param name="httpContext">请求上下文</param>
        /// <param name="addMsg">消息实体</param>
        /// <returns></returns>
        public async Task <ResModel <JObject> > AddLogiticOrder(AddMsg addMsg, HttpContext httpContext)
        {
            ResModel <JObject> res = new ResModel <JObject>();

            res.success       = "success";
            res.resultMessage = "推送消息成功!";
            var    type    = addMsg.stype; //test
            string strConn = _unDbConnection.GetDbConnStr();

            using (IDbConnection conn = DapperHelper.GetOpenConnection(strConn, DbProvider.SqlServer))
            {
                IDbTransaction transaction = conn.BeginTransaction();
                try
                {
                    //记录接口调用
                    string ipStr  = httpContext.Connection.RemoteIpAddress.ToString();
                    string sqlstr = @" insert into INTERFACE_CALL_LOG(FUNCTION_NAME,FUNCTION_PARAM,Ip,CALL_DATE)
                            select 'AddLogiticOrder ','addMsg;httpContext',@ip,getdate()";
                    await conn.ExecuteAsync(sqlstr, new { ip = ipStr }, transaction);

                    //记录推送过来的消息
                    sqlstr = @"insert into T_PUSHMSG (OrderNO,Types,MsgType,MsgTime,AddDate) select @orderNo,1,@msgType,@msgTime,getdate(); SELECT CAST(SCOPE_IDENTITY() as int)";
                    var pushID = await conn.QueryFirstAsync <int>(sqlstr, new { orderNo = addMsg.logisticsOrderNo, msgType = addMsg.stype, msgTime = addMsg.time }, transaction);;

                    //插入记录到消息队列中
                    sqlstr = @"insert into T_MsgQueue(InterfaceId,InterfaceName,ParamId,ProcessState) select '2.7','物流订单查询接口',@id,0; SELECT CAST(SCOPE_IDENTITY() as int)";
                    await conn.ExecuteAsync(sqlstr, new { id = addMsg.logisticsOrderNo }, transaction);

                    res.result = JObject.FromObject(new ResMsgDto()
                    {
                        msg = "推送消息成功!"
                    });

                    transaction.Commit();
                    conn.Close();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    res.success       = "false";
                    res.resultMessage = "推送消息失败:" + ex.Message;
                }
            }
            return(res);
        }
Ejemplo n.º 6
0
        private void onCompleted(object sender, PackEventArgs e)
        {
            SessionPack pack = sender as SessionPack;

            byte[] mResponseBuffer = pack.mResponseBuffer;
            if (e.isSuccess() && (mResponseBuffer != null))
            {
                byte[] response = Util.ReadProtoRawData(mResponseBuffer, 1);
                uint   Ret      = Util.ReadProtoInt(response, 1);

                RetConst ret    = (RetConst)Ret;
                int      offset = 0;

                if (ret == RetConst.MM_OK)
                {
                    uint          continueFlag = Util.ReadProtoInt(mResponseBuffer, 2);
                    List <object> list         = new List <object>();
                    List <object> msgList      = new List <object>();
                    Util.ReadProtoRawDataS(list, mResponseBuffer, 3);
                    foreach (var item in list)
                    {
                        AddMsg msg = AddMsg.ParseFrom((byte[])item);
                        msgList.Add(msg);
                    }

                    NetSceneNewSync.processAddMsgList(msgList);
                    Log.e("NetSceneGetChatRoomMsg", "continueFlag=" + continueFlag + " list Count=" + msgList.Count);

                    if (continueFlag != 0)
                    {
                        Log.e("NetSceneGetChatRoomMsg", "continueFlag=" + continueFlag + " list Count=" + msgList.Count + "buffre=" + Util.byteToHexStr(mResponseBuffer));
                    }

                    list.Clear();
                    msgList.Clear();
                }
            }
            else
            {
                Log.e("NetSceneGetChatRoomMsg", "NetSceneGetChatRoomMsg failed. ");
            }
        }
Ejemplo n.º 7
0
        public IHttpActionResult GetMsgMenu(AddMsg model)
        {
            var YourID = User.Identity.GetUserId();


            var wiadmosciMenu = (from menu in db.WiadomosciMenu
                                 join users in db.AspNetUsers on menu.dokogo equals users.Id
                                 where (menu.odkogo == YourID)
                                 orderby menu.data descending
                                 select new WiadomosciMenuLinq {
                Nazwa = users.UserName, Id = menu.id
            });

            foreach (var item in wiadmosciMenu)
            {
                var record = db.WiadomosciMenu.Where(a => a.id == item.Id).FirstOrDefault();
                record.isReaded = true;
            }
            db.SaveChanges();


            return(Ok(wiadmosciMenu));
        }
Ejemplo n.º 8
0
        public IHttpActionResult SendMsg(AddMsg model)
        {
            var YourID = User.Identity.GetUserId();


            var msg = new Wiadomosci();

            msg.odkogo   = YourID;
            msg.dokogo   = model.DoKogo;
            msg.tresc    = model.Text;
            msg.isReaded = false;

            db.Wiadomosci.Add(msg);
            //added



            var first = db.WiadomosciMenu.Where(a => a.odkogo == YourID && a.dokogo == model.DoKogo).FirstOrDefault();

            if (first == null)
            {
                var msgMenu = new WiadomosciMenu();


                msgMenu.odkogo   = YourID;
                msgMenu.dokogo   = model.DoKogo;
                msgMenu.data     = DateTime.Now;
                msgMenu.isReaded = true;

                db.WiadomosciMenu.Add(msgMenu);
            }
            else
            {
                first.data     = DateTime.Now;
                first.isReaded = true;
            }

            var second = db.WiadomosciMenu.Where(a => a.odkogo == model.DoKogo && a.dokogo == YourID).FirstOrDefault();

            if (second == null)
            {
                var msgMenu = new WiadomosciMenu();


                msgMenu.odkogo   = model.DoKogo;
                msgMenu.dokogo   = YourID;
                msgMenu.data     = DateTime.Now;
                msgMenu.isReaded = false;

                db.WiadomosciMenu.Add(msgMenu);
            }
            else
            {
                second.data     = DateTime.Now;
                second.isReaded = false;
            }


            //var second = db.WiadomosciMenu.Where(a=> a.odkogo == model.DoKogo && a.dokogo == YourID).FirstOrDefault();



            db.SaveChanges();

            return(Ok("Wiadmosc doszla"));
        }
Ejemplo n.º 9
0
        static void AddSuccess(ref AddMsg msg, MyNetworkClient sender)
        {
            MyGps gps=new MyGps();
            gps.Name=msg.Name;
            gps.Description=msg.Description;
            gps.Coords=msg.Coords;
            gps.ShowOnHud=msg.ShowOnHud;
            gps.DiscardAt=null;
            if (!msg.IsFinal)
               gps.SetDiscardAt();
            gps.UpdateHash();
            if (MySession.Static.Gpss.AddPlayerGps(msg.IdentityId, ref gps))
            {//new entry succesfully added
                if (gps.ShowOnHud && msg.IdentityId == MySession.LocalPlayerId)
                    MyHud.GpsMarkers.RegisterMarker(gps);
            }

            var handler = MySession.Static.Gpss.ListChanged;
            if (handler != null)
            {
                handler(msg.IdentityId);
            }
        }
Ejemplo n.º 10
0
 static void AddRequest(ref AddMsg msg, MyNetworkClient sender)
 {
     Sync.Layer.SendMessageToAllAndSelf(ref msg, MyTransportMessageEnum.Success);
 }
Ejemplo n.º 11
0
        public void RefreshMsg(object sender, TEventArgs <List <AddMsg> > e)
        {
            try
            {
                List <AddMsg>                msg      = e.Result;
                string                       dicitems = "FromUserName,FromUserNikeName,FromMemberName,FromMemerNikeName,ToUserName,ToUserNikeName,AtNikeNames,Message,MsgTime";
                string[]                     itemArr  = dicitems.Split(',');
                List <wxMessageClass>        messages = new List <wxMessageClass>();
                Dictionary <string, Contact> AllUsers = contactDict;
                //List<string> msgs = tbox.Lines.ToList();
                //List<ListViewItem> msgs = new List<ListViewItem>();
                for (int i = 0; i < msg.Count; i++)
                {
                    AddMsg wxmsg = msg[i];
                    if (wxmsg.MsgType != MsgType.MM_DATA_TEXT)
                    {
                        continue;
                    }
                    string fromName = wxmsg.FromUserName;
                    string NickName = fromName;
                    if (AllUsers.ContainsKey(fromName))//联系人发来的
                    {
                        ////if(fromName.StartsWith("@@"))
                        ////{
                        ////    client.GetBatchGetContactAsync(string.Join(",",AllUsers[fromName].MemberDict.Keys.ToArray()),fromName);
                        ////}
                        NickName = AllUsers[fromName].NickName;
                        if (AllUsers[fromName].MemberList.Count > 0) //是群
                        {
                            if (!AllUsers[fromName].DisplayNikeName) //所有的群都显示昵称
                            {
                                client.GetBatchGetContactAsync(string.Join(",", AllUsers[fromName].MemberList.Select(a => a.UserName)), fromName);
                                AllUsers[fromName].DisplayNikeName = true;
                            }
                        }
                    }
                    else
                    {
                        client.GetBatchGetContactAsync(fromName);
                        continue;
                    }
                    string ToName     = wxmsg.ToUserName;
                    string ToNameNike = null;
                    if (AllUsers.ContainsKey(ToName))
                    {
                        ToNameNike = AllUsers[ToName].NickName;
                    }

                    //string[] strMsg = new string[5];
                    wxMessageClass wmsg = new wxMessageClass();

                    if (wxmsg.MsgType == MsgType.MM_DATA_IMG)
                    {
                        string strImg = wxmsg.Content;
                    }

                    if (fromName.StartsWith("@@"))
                    {
                        string[] content = wxmsg.Content.Split(new string[] { ":<br/>" }, StringSplitOptions.RemoveEmptyEntries);
                        content[1] = content[1].Replace("<br/>", "\r\n");
                        string memName = "";
                        if (1 == 2 && AllUsers.ContainsKey(content[0]))
                        {
                            memName = AllUsers[content[0]].DisplayName;
                            if (string.IsNullOrEmpty(memName))
                            {
                                memName = AllUsers[content[0]].NickName;
                            }
                        }
                        else
                        {
                            if (AllUsers[fromName].MemberDict.ContainsKey(content[0]))
                            {
                                memName = AllUsers[fromName].MemberDict[content[0]].DisplayName;
                            }
                            if (string.IsNullOrEmpty(memName) && AllUsers.ContainsKey(fromName) && AllUsers[fromName].MemberDict.ContainsKey(content[0]))
                            {
                                memName = AllUsers[fromName].MemberDict[content[0]].NickName;
                            }
                        }

                        //strMsg = string.Format("[{0}]{1}:{2}", NickName, memName, string.Join("",content.Skip(1).ToArray()));
                        //strMsg = new string[] { DateTime.Now.ToShortTimeString(), NickName, memName, "", string.Join("", content.Skip(1).ToArray()) };
                        wmsg.FromUserNam        = fromName;
                        wmsg.FromNikeName       = NickName;
                        wmsg.FromMemberUserName = content[0];
                        wmsg.FromMemberNikeName = memName;
                        wmsg.CreateTime         = wxmsg.CreateTime;
                        wmsg.Msg    = content[1];
                        wmsg.OrgMsg = wxmsg.Content;
                        Regex           regTr  = new Regex(@"@(.*?) ");
                        List <string>   atlist = new List <string>();
                        MatchCollection mcs    = regTr.Matches(wmsg.Msg);
                        for (int mi = 0; mi < mcs.Count; mi++)
                        {
                            atlist.Add(mcs[mi].Value.Trim().Replace("@", ""));
                        }
                        wmsg.AtMemberNikeName = atlist.ToArray();
                        if (wmsg.AtMemberNikeName != null && wmsg.AtMemberNikeName.Length == 1)
                        {
                            var matchnicks = AllUsers[fromName].MemberDict.Where(a => a.Value.DisplayName == wmsg.AtMemberNikeName[0] || a.Value.NickName == wmsg.AtMemberNikeName[0]);
                            foreach (var mem in matchnicks)
                            {
                                if (mem.Value.UserName == client.user.UserName)
                                {
                                    wmsg.IsAtToMe = true;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        wmsg.FromUserNam        = fromName;
                        wmsg.FromNikeName       = NickName;
                        wmsg.FromMemberUserName = null;
                        wmsg.FromMemberNikeName = null;
                        wmsg.ToUserName         = ToName;
                        wmsg.ToNikeName         = ToNameNike;
                        wmsg.CreateTime         = wxmsg.CreateTime;
                        wmsg.Msg    = wxmsg.Content.Replace("<br/>", "\r\t");
                        wmsg.OrgMsg = wxmsg.Content;
                    }
                    messages.Add(wmsg);
                    //msgs.Add(new ListViewItem(strMsg));
                }
                if (messages.Count > 0)
                {
                    Task.Run(() => {
                        MsgProcessCompleted?.Invoke(this, messages);
                    });
                    Task.Run(() => {
                        InjectBuffs(messages);
                    });
                    //?.Invoke(this, messages);
                    ////if(MsgProcessCompleted_ForExtralInterfaceInvoke!=null)
                    ////{
                    ////    MsgProcessCompleted_ForExtralInterfaceInvoke.ForEach(
                    ////        a => {
                    ////            a.Invoke(this, messages);
                    ////        }
                    ////        );
                    ////}
                }
            }
            catch (Exception ce)
            {
                MessageBox.Show(string.Format("{0}:{1}", ce.Message, ce.StackTrace));
            }
            //tbox.Lines = msgs.ToArray();
            //tbox.Focus();
            //tbox.Select(tbox.Text.Length, 0);
            //tbox.ScrollToCaret();
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 推送新增物流订单消息
 /// </summary>
 /// <param name="addMsg">消息实体</param>
 /// <param name="context">请求上下文 </param>
 /// <returns></returns>
 public async Task <ResModel <JObject> > AddLogiticOrder(AddMsg addMsg, HttpContext context)
 {
     return(await _unionDal.AddLogiticOrder(addMsg, context));
 }
Ejemplo n.º 13
0
        static void AddRequest(ref AddMsg msg, MyNetworkClient sender)
        {
            Dictionary<int, MyGps> insList;
            var result = MySession.Static.Gpss.m_playerGpss.TryGetValue(msg.IdentityId, out insList);

            if (result != null)
            {
                Sync.Layer.SendMessageToAllAndSelf(ref msg, MyTransportMessageEnum.Success);
            }
        }
Ejemplo n.º 14
0
        static void OnAddGps(AddMsg msg)
        {
            MyGps gps = new MyGps();
            gps.Name = msg.Name;
            gps.Description = msg.Description;
            gps.Coords = msg.Coords;
            gps.ShowOnHud = msg.ShowOnHud;
            gps.AlwaysVisible = msg.AlwaysVisible;
            gps.DiscardAt = null;
            if (!msg.IsFinal)
                gps.SetDiscardAt();
            gps.UpdateHash();
            if(msg.EntityId > 0)
                gps.SetEntity(MyEntities.GetEntityById(msg.EntityId));
            if (MySession.Static.Gpss.AddPlayerGps(msg.IdentityId, ref gps))
            {//new entry succesfully added
                if (gps.ShowOnHud && msg.IdentityId == MySession.Static.LocalPlayerId)
                    MyHud.GpsMarkers.RegisterMarker(gps);
            }

            var handler = MySession.Static.Gpss.ListChanged;
            if (handler != null)
            {
                handler(msg.IdentityId);
            }
        }
Ejemplo n.º 15
0
        public void RefreshMsg(ListView msglist, List <AddMsg> msg)
        {
            //List<string> msgs = tbox.Lines.ToList();
            List <ListViewItem> msgs = new List <ListViewItem>();

            for (int i = 0; i < msg.Count; i++)
            {
                AddMsg wxmsg = msg[i];
                if (wxmsg.MsgType != MsgType.MM_DATA_TEXT)
                {
                    continue;
                }
                string fromName = wxmsg.FromUserName;
                string NickName = fromName;
                if (this.AllUsers.ContainsKey(fromName))//联系人发来的
                {
                    ////if(fromName.StartsWith("@@"))
                    ////{
                    ////    client.GetBatchGetContactAsync(string.Join(",",this.AllUsers[fromName].MemberDict.Keys.ToArray()),fromName);
                    ////}
                    NickName = this.AllUsers[fromName].NickName;
                    if (this.AllUsers[fromName].MemberList.Count > 0) //是群
                    {
                        if (!this.AllUsers[fromName].DisplayNikeName) //所有的群都显示昵称
                        {
                            client.GetBatchGetContactAsync(string.Join(",", AllUsers[fromName].MemberList.Select(a => a.UserName)), fromName);
                            this.AllUsers[fromName].DisplayNikeName = true;
                        }
                    }
                }
                else
                {
                    client.GetBatchGetContactAsync(fromName);
                    continue;
                }
                string ToName     = wxmsg.ToUserName;
                string ToNameNike = null;
                if (this.AllUsers.ContainsKey(ToName))
                {
                    ToNameNike = this.AllUsers[ToName].NickName;
                }

                string[] strMsg = new string[5];
                if (fromName.StartsWith("@@"))
                {
                    string[] content = wxmsg.Content.Split(new string[] { ":<br/>" }, StringSplitOptions.RemoveEmptyEntries);
                    content[1] = content[1].Replace("<br/>", "\r\n");
                    string memName = "";
                    if (1 == 2 && this.AllUsers.ContainsKey(content[0]))
                    {
                        memName = this.AllUsers[content[0]].DisplayName;
                        if (string.IsNullOrEmpty(memName))
                        {
                            memName = this.AllUsers[content[0]].NickName;
                        }
                    }
                    else
                    {
                        if (this.AllUsers[fromName].MemberDict.ContainsKey(content[0]))
                        {
                            memName = this.AllUsers[fromName].MemberDict[content[0]].DisplayName;
                        }
                        if (string.IsNullOrEmpty(memName))
                        {
                            memName = this.AllUsers[fromName].MemberDict[content[0]].NickName;
                        }
                    }

                    //strMsg = string.Format("[{0}]{1}:{2}", NickName, memName, string.Join("",content.Skip(1).ToArray()));
                    strMsg = new string[] { DateTime.Now.ToShortTimeString(), NickName, memName, "", string.Join("", content.Skip(1).ToArray()) };
                }
                else
                {
                    if (ToName.StartsWith("@@"))
                    {
                        //strMsg = string.Format("{0}<{1}>:{2}", ToNameNike, NickName, wxmsg.Content.Replace("<br/>", "\r\t"));
                        strMsg = new string[] { DateTime.Now.ToShortTimeString(), ToNameNike, NickName, "", wxmsg.Content.Replace("<br/>", "\r\t") };
                    }
                    else
                    {
                        //strMsg = string.Format("{0}:{1}", NickName, wxmsg.Content.Replace("<br/>", "\r\t"));
                        strMsg = new string[] { DateTime.Now.ToShortTimeString(), NickName, "", "", wxmsg.Content.Replace("<br/>", "\r\t") };
                    }
                }

                msgs.Add(new ListViewItem(strMsg));
            }
            //tbox.Lines = msgs.ToArray();
            //tbox.Focus();
            //tbox.Select(tbox.Text.Length, 0);
            //tbox.ScrollToCaret();

            listView_msg.Items.AddRange(msgs.ToArray());
            //listView_msg.sel
            int cnt = listView_msg.Items.Count;

            listView_msg.MultiSelect = false;
            //listView_msg.Items[cnt - 1].Selected = true;
            //listView_msg.Items[cnt - 1].Focused = true;
            if (cnt > 0)
            {
                listView_msg.Items[cnt - 1].EnsureVisible();
            }
        }
Ejemplo n.º 16
0
        public static bool downloadVoiceInfo(AddMsg cmdAM)
        {
            MsgTrans voiceinfo = new MsgTrans
            {
                nTransType      = 4,
                nStatus         = 0,
                strToUserName   = cmdAM.ToUserName.String,
                strFromUserName = cmdAM.FromUserName.String
            };
            string xmlStr = cmdAM.Content.String;

            if (ContactMgr.getUserType(cmdAM.FromUserName.String) == ContactMgr.UserType.UserTypeChatRoom)
            {
                xmlStr = xmlStr.Substring(xmlStr.IndexOf('\n') + 1);
            }
            if (!parseVoiceMsgXML(xmlStr, voiceinfo))
            {
                Log.d("DownloadVoiceService", "parseVoiceMsgXML failed");
                return(false);
            }
            voiceinfo.nMsgSvrID = cmdAM.MsgId;
            if (AccountMgr.getCurAccount().strUsrName == voiceinfo.strFromUserName)
            {
                Log.d("DownloadVoiceService", "the mVoiceinfo.strFromUserName is yourself");
                return(false);
            }
            if (isCancelVoiceMsg(xmlStr))
            {
                Log.d("DownloadVoiceService", "the msg has been canceled");
                //StorageMgr.chatMsg.delMsg(ChatMsgHelper.getTalker(voiceinfo.strToUserName, voiceinfo.strFromUserName), voiceinfo.nMsgSvrID);
                voiceinfo.nStatus = 5;
                //DownloadVoiceStorage.updateDownloadVoiceContext(voiceinfo);
                DownloadVoiceContext context = DownloadVoiceContextMgr.getInstance().GetBySvrID(cmdAM.MsgId);
                if (context != null)
                {
                    context.mStatus = 5;
                }
                return(false);
            }
            if ((cmdAM.ImgBuf != null) && (cmdAM.ImgBuf.Buffer.Length != 0))
            {
                return(saveShortVoiceInfo(voiceinfo, cmdAM.ImgBuf.Buffer.ToByteArray()));
            }
            DownloadVoiceContext bySvrID = DownloadVoiceContextMgr.getInstance().GetBySvrID(cmdAM.MsgId);

            if (bySvrID == null)
            {
                bySvrID = new DownloadVoiceContext(cmdAM.MsgId, ChatMsgHelper.getTalker(cmdAM.ToUserName.String, cmdAM.FromUserName.String))
                {
                    mStatus = 0
                };
                bySvrID.Enqueue(voiceinfo);
                DownloadVoiceContextMgr.getInstance().putToTail(bySvrID);
            }
            else
            {
                bySvrID.Enqueue(voiceinfo);
            }
            //DownloadVoiceStorage.updateDownloadVoiceContext(voiceinfo);
            doSceneBegin();
            return(true);
        }
Ejemplo n.º 17
0
 static void AddRequest(ref AddMsg msg, MyNetworkClient sender)
 {
     Sync.Layer.SendMessageToAllAndSelf(ref msg, MyTransportMessageEnum.Success);
 }
Ejemplo n.º 18
0
        //ADD:
        public void SendAddGps(long identityId, ref MyGps gps)
        {
            var msg = new AddMsg();
            msg.IdentityId=identityId;
            msg.Name=gps.Name;
            msg.Description=gps.Description;
            msg.Coords=gps.Coords;
            msg.ShowOnHud=gps.ShowOnHud;
            msg.IsFinal=(gps.DiscardAt==null?true:false);

            Sync.Layer.SendMessageToServer(ref msg, MyTransportMessageEnum.Request);
        }
Ejemplo n.º 19
0
        public static Message CreateMessage(AddMsg msg)
        {
            //MsgType
            //1   文本消息
            //3   图片消息
            //34  语音消息
            //37  VERIFYMSG
            //40  POSSIBLEFRIEND_MSG
            //42  共享名片
            //43  视频通话消息
            //47  动画表情
            //48  位置消息
            //49  分享链接
            //50  VOIPMSG
            //51  微信初始化消息
            //52  VOIPNOTIFY
            //53  VOIPINVITE
            //62  小视频
            //9999    SYSNOTICE
            //10000   系统消息
            //10002   撤回消息

            bool    isSend = IsSend(msg.FromUserName);
            Contact remote = (isSend) ? WechatAPIService.GetContact(msg.ToUserName) : WechatAPIService.GetContact(msg.FromUserName);

            Message ret = new Message();

            switch (msg.MsgType)
            {
            case 1:
                ret.Content = msg.Content;
                break;

            case 3:

                string sevePath = Path.Combine(m_Service.CachePath, DateTime.Now.Ticks + ".bmp");
                ret.fileName = sevePath;
                ret.FileSize = msg.FileSize;
                string thumbnail = string.Format("/cgi-bin/mmwebwx-bin/webwxgetmsgimg?MsgID={0}&type=slave", msg.MsgId);
                ret.Content = string.Format("/cgi-bin/mmwebwx-bin/webwxgetmsgimg?MsgID={0}", msg.MsgId);

                Image image = m_Service.GetMsgImage(thumbnail);
                if (image == null)
                {
                    break;
                }
                image.Save(sevePath);
                break;

            case 34:
                sevePath        = Path.Combine(m_Service.CachePath, DateTime.Now.Ticks + ".MP3");
                ret.fileName    = sevePath;
                ret.FileSize    = msg.FileSize;
                ret.VoiceLength = msg.VoiceLength;
                string url = string.Format("/cgi-bin/mmwebwx-bin/webwxgetvoice?MsgID={0}", msg.MsgId);
                m_Service.GetMsgFile(url, sevePath);

                break;

            case 47:
                //下载图片
                sevePath     = Path.Combine(m_Service.CachePath, Path.GetRandomFileName());
                ret.fileName = sevePath;
                ret.FileSize = msg.FileSize;
                if (string.IsNullOrEmpty(msg.Content))
                {
                    break;
                }

                url = XMLTools.GetImageUrl(msg.Content);
                if (string.IsNullOrEmpty(url))
                {
                    break;
                }
                image = m_Service.GetImage(url);
                if (image == null)
                {
                    break;
                }
                image.Save(sevePath);
                break;

            default:
                ret.Content = msg.Content;
                break;
            }
            if (ret == null)
            {
                ret = new Message();
            }
            ret.MsgType       = msg.MsgType;
            ret.IsSend        = isSend;
            ret.Remote        = remote;
            ret.FromContactID = msg.FromUserName;
            ret.ToContactD    = msg.ToUserName;
            ret.Mime          = WechatAPIService.Self;
            ret.MsgId         = msg.MsgId;
            if (msg.MsgType != 51)
            {
                DaoMaster.GetSession().GetMessageDao().InsertMessage(ret, remote.Seq);
            }

            return(ret);
        }
Ejemplo n.º 20
0
 public RecvMessageEvent(AddMsg msg)
 {
     Msg = msg;
 }