Ejemplo n.º 1
0
        public static void onTimerHandler(object sender, EventArgs e)
        {
            NetSceneDownloadVoice voice = TimerEventArgs.getObject(e) as NetSceneDownloadVoice;

            if (voice == null)
            {
                Log.e("NetSceneDownloadVoice", "onTimerHandler, invalid timer args");
            }
            else if (voice.mVoiceContext == null)
            {
                Log.d("NetSceneDownloadVoice", "scene.mVoiceContext is null,doScene already finished");
            }
            else if (voice.mVoiceContext.isBlockRunning())
            {
                Log.d("NetSceneDownloadVoice", "doScene recving msg block now status=" + voice.mVoiceContext.mStatus);
            }
            else
            {
                Log.i("NetSceneDownloadVoice", "doScene start download msg block now status=" + voice.mVoiceContext.mStatus);
                MsgTrans currentVoiceBlock = voice.mVoiceContext.GetCurrentVoiceBlock();
                if (currentVoiceBlock == null)
                {
                    if (voice.mTimerObject.FireCount > 300)
                    {
                        Log.e("NetSceneDownloadVoice", "the block timer reached the max times = " + 300);
                        voice.doSceneFinished(5);
                        voice.cancel();
                    }
                }
                else
                {
                    voice.doSceneBlock(currentVoiceBlock);
                }
            }
        }
Ejemplo n.º 2
0
        //public bool doCancel()
        //{
        //    if (this.mVideoContext != null)
        //    {
        //        CDNComService.Instance.cancelUploadMedia(this.mVideoContext.mVideoTrans.strClientMsgId);
        //        base.cancel();
        //        this.mVideoContext.mStatus = 4;
        //        this.doSceneFinished();
        //    }
        //    return true;
        //}

        //private void doReportInfo(int retCode)
        //{
        //    int num = this.mVideoContext.mVideoTrans.nTotalDataLen + this.mVideoContext.mThumbTotalLength;
        //    string str = string.Concat(new object[] { retCode, ",", 1, ",", (long) this.mVideoContext.startTimestamp, ",", (long) Util.getNowMilliseconds(), ",", ReportService.getReportNetworkType(), ",", CdnMediaType.MediaType_VIDEO, ",", num, ",", this.mCdnComReportInfo });
        //    NetSceneKVReport.addReportItem(0x28b5, str);
        //}

        //public void doScene(UploadVideoContext videoContext)
        //{
        //    if ((videoContext.mStatus != 0) && (videoContext.mStatus != 4))
        //    {
        //        Log.e("NetSceneUploadVideo", "doScene videoContext.mStatus error, status = " + videoContext.mStatus);
        //    }
        //    else
        //    {
        //        videoContext.mStatus = 1;
        //        this.mVideoContext = videoContext;
        //        this.mVideoContext.mSceneHandle = this;
        //        this.doSceneToCDN();
        //    }
        //}

        //public void doSceneFinished()
        //{
        //    if (this.mVideoContext != null)
        //    {
        //        this.mVideoContext.updateProgressInfo(0);
        //        this.mVideoContext.updateContext();
        //        this.mVideoContext.onFinished();
        //        this.mVideoContext.mSceneHandle = null;
        //        this.mVideoContext = null;
        //        Log.d("NetSceneUploadVideo", "scene Finished. ");
        //    }
        //}

        //private int doSceneToCDN()
        //{
        //    RTCDNUploadPara para = new RTCDNUploadPara {
        //        fileFullPath = this.mVideoContext.mVideoTrans.strImagePath,
        //        filetype = 4,
        //        toUser = this.mVideoContext.mVideoTrans.strToUserName,
        //        clientMediaID = this.mVideoContext.mChatMsg.strClientMsgId,
        //        arg = 0,
        //        hasThumb = true,
        //        thumbfileFullPath = this.mVideoContext.mVideoTrans.strThumbnail
        //    };
        //    this.mVideoContext.doCloseFile();
        //    para.needStorage = false;
        //    para.isStreamMedia = false;
        //    para.priority = 2;
        //    if (this.mVideoContext.mChatMsg.nMsgType == 0x3e)
        //    {
        //        para.smallVideoFlag = 1;
        //    }
        //    if (this.mVideoContext.mOrigChatMsg != null)
        //    {
        //        Log.d("NetSceneUploadVideo", "forward video msg , mOrigChatMsg = " + this.mVideoContext.mOrigChatMsg.strMsg);
        //        VideoDetailInfo info = UploadVideoService.parseVideoMsgXML(this.mVideoContext.mOrigChatMsg.strMsg);
        //        if (((info != null) && !string.IsNullOrEmpty(info.mCdnAesKey)) && !string.IsNullOrEmpty(info.mCdnVideoUrl))
        //        {
        //            para.fileid = info.mCdnVideoUrl;
        //            para.aeskey = info.mCdnAesKey;
        //            para.fileLength = (uint) info.nTotalDataLen;
        //        }
        //        else
        //        {
        //            Log.d("NetSceneUploadVideo", "Parse video msg xml failed: " + this.mVideoContext.mOrigChatMsg.strMsg);
        //        }
        //    }
        //    return CDNComService.Instance.startupUploadMedia(para, this);
        //}

        public void doSceneToCGI(string toUsername, MsgTrans videoinfo, DownloadVideoContext contextInfo, int nMsgType)
        {
            base.beginBuilder();
            base.mBuilder.BaseRequest       = NetSceneBase.makeBaseRequest(0);
            base.mBuilder.FromUserName      = videoinfo.strToUserName;
            base.mBuilder.ToUserName        = toUsername;
            base.mBuilder.ClientMsgId       = videoinfo.nMsgSvrID.ToString();
            base.mBuilder.PlayLength        = (uint)videoinfo.nDuration;
            base.mBuilder.NetworkEnv        = 1;
            base.mBuilder.CameraType        = 2;
            base.mSessionPack.mCmdID        = 0x27;
            base.mSessionPack.mNeedCompress = false;
            base.mBuilder.VideoTotalLen     = (uint)videoinfo.nTotalDataLen;
            base.mBuilder.VideoStartPos     = 0;
            base.mBuilder.VideoData         = Util.toSKBuffer(new byte[0]);
            base.mBuilder.ThumbTotalLen     = (uint)contextInfo.mCdnThumbLength;
            base.mBuilder.ThumbStartPos     = 0;
            base.mBuilder.ThumbData         = Util.toSKBuffer(new byte[0]);
            base.mBuilder.CDNVideoUrl       = contextInfo.mCdnVideoUrl;
            base.mBuilder.AESKey            = contextInfo.mCdnAesKey;
            base.mBuilder.EncryVer          = 1;
            base.mBuilder.CDNThumbUrl       = contextInfo.mCdnThumbUrl;
            base.mBuilder.CDNThumbImgSize   = contextInfo.mCdnThumbLength;
            base.mBuilder.CDNThumbImgWidth  = 0x84;
            base.mBuilder.CDNThumbImgHeight = 0x63;
            base.mBuilder.CDNThumbAESKey    = contextInfo.mCdnThumbAesKey;
            if (nMsgType == 0x3e)//小视频
            {
                base.mBuilder.FuncFlag = 3;
                base.mBuilder.VideoMd5 = Util.nullAsNil("");
            }
            base.endBuilder();
        }
Ejemplo n.º 3
0
        public static UploadVideoContext createByClientMsgID(string clientMsgID)
        {
            MsgTrans trans = new MsgTrans {
                nTransType     = 5,
                strClientMsgId = clientMsgID
            };

            return(new UploadVideoContext {
                mVideoTrans = trans
            });
        }
Ejemplo n.º 4
0
        public bool fillContextWithOrigStream()
        {
            if ((this.imgBUf == null) || (this.imgBUf.Length <= 0L))
            {
                return(false);
            }
            copyImageStreamToMem(imgBUf);
            if ((this.chatMsgInfo == null) || string.IsNullOrEmpty(this.chatMsgInfo.strClientMsgId))
            {
                return(false);
            }
            if (this.imgInfo == null)
            {
                this.imgInfo                = new MsgTrans();
                this.imgInfo.nCreateTime    = (long)(Util.getNowMilliseconds() / 1000.0);
                this.imgInfo.strToUserName  = this.talkerName;
                this.imgInfo.nStatus        = 2;
                this.imgInfo.nTransType     = 1;
                this.imgInfo.strClientMsgId = this.chatMsgInfo.strClientMsgId;

                this.imgInfo.nTotalDataLen = imgBUf.Length;
                this.imgInfo.nTransDataLen = 0;

                //if (!this.saveImageOnLocal(this.filename, this.origStream))
                //{
                //    Log.e("UpLoadImgContext", "saveImageOnLocal fail!");
                //    return false;
                //}
                if (this.imgInfo.nTotalDataLen <= 0)
                {
                    Log.e("UpLoadImgContext", "saveImageOnLocal fail len =" + this.imgInfo.nTotalDataLen);
                    return(false);
                }
                if (this.chatMsgInfo == null)
                {
                    this.chatMsgInfo = new ChatMsg();
                }
                this.chatMsgInfo.strTalker    = this.talkerName;
                this.chatMsgInfo.nMsgType     = this.mMsgType;
                this.chatMsgInfo.nStatus      = 0;
                this.chatMsgInfo.nIsSender    = 1;
                this.chatMsgInfo.strThumbnail = this.imgInfo.strThumbnail;
                this.chatMsgInfo.strPath      = this.imgInfo.strImagePath;
                //StorageMgr.chatMsg.updateMsg(this.chatMsgInfo);
                this.imgInfo.nMsgLocalID = this.chatMsgInfo.nMsgLocalID;
                // StorageMgr.msgImg.add(this.imgInfo);
                //copyImageStreamToMem()
            }
            return(true);
        }
Ejemplo n.º 5
0
 public static bool needResumeFromTrans(MsgTrans msgTrans, uint now)
 {
     if (msgTrans.nStatus == 5)
     {
         Log.d("UploadVoiceContext", "comleted task, ignored.");
         return(false);
     }
     if (!isSaveCompleted(msgTrans))
     {
         Log.d("UploadVoiceContext", "not saved task, ignored.");
         return(false);
     }
     return(true);
 }
Ejemplo n.º 6
0
        public static UploadVoiceContext createByClientMsgID(string clientMsgID)
        {
            // MsgTrans msgTrans = StorageMgr.msgVoice.getByClientMsgID(clientMsgID);
            // if (msgTrans == null)
            //  {
            MsgTrans msgTrans = new MsgTrans
            {
                nTransType     = 3,
                strClientMsgId = clientMsgID
            };

            return(createByMsgTrans(msgTrans));
            //  }
            // return createByMsgTrans(msgTrans);
        }
Ejemplo n.º 7
0
        private bool doSceneBlock(MsgTrans voiceinfo)
        {
            Log.i("NetSceneDownloadVoice", string.Concat(new object[] { "NetSceneDownloadVoice do scene,download a msg block, endflag=", voiceinfo.nEndFlag, " svrMsgID=", voiceinfo.nMsgSvrID }));
            this.mVoiceContext.mStatus = 2;
            base.beginBuilder();
            base.mBuilder.BaseRequest = NetSceneBase.makeBaseRequest(20);
            base.mBuilder.MsgId       = (uint)this.mVoiceContext.mMsgSvrID;
            base.mBuilder.Offset      = (uint)this.mVoiceContext.mOffset;
            voiceinfo.nTransDataLen   = this.mVoiceContext.mOffset;
            uint num = (uint)(voiceinfo.nTotalDataLen - voiceinfo.nTransDataLen);

            base.mBuilder.Length = (num > 0x10000) ? 0x10000 : num;
            if ((voiceinfo.strClientMsgId != null) && (voiceinfo.strClientMsgId.Length > 0))
            {
                base.mBuilder.ClientMsgId = voiceinfo.strClientMsgId;
            }
            base.mSessionPack.mCmdID = 20;
            base.endBuilder();
            return(true);
        }
Ejemplo n.º 8
0
        public void doSceneFinished(int status)
        {
            Log.i("NetSceneDownloadVoice", "netscene do finished. status=" + status);
            this.mVoiceContext.mStatus = status;
            MsgTrans voiceinfo = new MsgTrans {
                nMsgSvrID = this.mVoiceContext.mMsgSvrID,
                nStatus   = this.mVoiceContext.mStatus
            };

            // DownloadVoiceStorage.updateDownloadVoiceContext(voiceinfo);
            if (this.mTimerObject != null)
            {
                this.mTimerObject.stop();
                this.mTimerObject = null;
            }
            if (this.mOnSceneFinished != null)
            {
                this.mOnSceneFinished(this.mVoiceContext);
            }
            this.mVoiceContext = null;
        }
Ejemplo n.º 9
0
        public static bool parseVoiceMsgXML(string xmlStr, MsgTrans voiceinfo)
        {
            if (string.IsNullOrEmpty(xmlStr) || (voiceinfo == null))
            {
                Log.d("DownloadVoiceService", "parseVoiceMsgXML, input invalid para");
                return(false);
            }
            XElement element = null;

            try
            {
                element = XDocument.Parse(xmlStr).Element("msg").Element("voicemsg");
                XAttribute attribute = element.Attribute("clientmsgid");
                if (attribute != null)
                {
                    voiceinfo.strClientMsgId = attribute.Value;
                }
                attribute = element.Attribute("length");
                if (attribute != null)
                {
                    voiceinfo.nTotalDataLen = int.Parse(attribute.Value);
                }
                attribute = element.Attribute("endflag");
                if (attribute != null)
                {
                    voiceinfo.nEndFlag = int.Parse(attribute.Value);
                }
                attribute = element.Attribute("voicelength");
                if (attribute != null)
                {
                    voiceinfo.nDuration = int.Parse(attribute.Value);
                }
            }
            catch (Exception exception)
            {
                Log.d("DownloadVoiceService", exception.Message);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 10
0
        public static bool reDownloadVoiceInfo(ChatMsg msg)
        {
            MsgTrans voiceinfo = new MsgTrans
            {
                nTransType      = 4,
                nStatus         = 0,
                strToUserName   = AccountMgr.getCurAccount().strUsrName,
                strFromUserName = msg.strTalker
            };
            string strMsg = msg.strMsg;

            if (ContactMgr.getUserType(msg.strTalker) == ContactMgr.UserType.UserTypeChatRoom)
            {
                strMsg = strMsg.Substring(strMsg.IndexOf('\n') + 1);
            }
            if (!parseVoiceMsgXML(strMsg, voiceinfo))
            {
                Log.d("DownloadVoiceService", "parseVoiceMsgXML failed");
                return(false);
            }
            voiceinfo.nMsgSvrID = msg.nMsgSvrID;
            if (AccountMgr.getCurAccount().strUsrName == voiceinfo.strFromUserName)
            {
                Log.d("DownloadVoiceService", "the mVoiceinfo.strFromUserName is yourself");
                return(false);
            }
            if (DownloadVoiceContextMgr.getInstance().GetBySvrID(msg.nMsgSvrID) == null)
            {
                DownloadVoiceContext context = new DownloadVoiceContext(msg.nMsgSvrID, msg.strTalker)
                {
                    mStatus = 0
                };
                context.Enqueue(voiceinfo);
                DownloadVoiceContextMgr.getInstance().putToTail(context);
                //DownloadVoiceStorage.updateDownloadVoiceContext(voiceinfo);
                doSceneBegin();
            }
            return(true);
        }
Ejemplo n.º 11
0
        public bool UpdateQueue(MsgTrans voiceinfo)
        {
            if (voiceinfo == null)
            {
                Log.d("DownloadVoiceContext", "invalid voiceinfo");
                return(false);
            }
            bool flag = false;

            foreach (MsgTrans trans in this.mVoiceMsgQueue)
            {
                if ((trans.nMsgSvrID == voiceinfo.nMsgSvrID) && (trans.strClientMsgId == voiceinfo.strClientMsgId))
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                this.mVoiceMsgQueue.Enqueue(voiceinfo);
            }
            return(true);
        }
Ejemplo n.º 12
0
        public static bool saveShortVoiceInfo(MsgTrans voiceinfo, byte[] voiceBuf)
        {
            voiceinfo.nStatus = 4;
            try
            {
                byte[] bytes = new UTF8Encoding().GetBytes("#!AMR\n");

                if (Directory.Exists(System.IO.Directory.GetCurrentDirectory() + "\\Cache\\" + voiceinfo.strFromUserName) == false)//如果不存在就创建file文件夹
                {
                    Directory.CreateDirectory(System.IO.Directory.GetCurrentDirectory() + "\\Cache\\" + voiceinfo.strFromUserName + "\\Voice");
                    Directory.CreateDirectory(System.IO.Directory.GetCurrentDirectory() + "\\Cache\\" + voiceinfo.strFromUserName + "\\Img");
                }

                using (FileStream fs = new FileStream(System.IO.Directory.GetCurrentDirectory() + "\\Cache\\" + voiceinfo.strFromUserName + "\\Voice\\" + voiceinfo.nMsgSvrID.ToString() + ".amr", FileMode.Create))
                {
                    int len = voiceinfo.nTotalDataLen + voiceBuf.Length;


                    byte[] dst = new byte[voiceBuf.Length + bytes.Length];
                    Buffer.BlockCopy(bytes, 0, dst, 0, bytes.Length);
                    Buffer.BlockCopy(voiceBuf, 0, dst, bytes.Length, voiceBuf.Length);
                    fs.Write(voiceBuf, 0, voiceBuf.Length);
                    fs.Close();
                    //上传语音
                    //消息转发代码
                    if (RedisConfig.IsLive)
                    {
                        foreach (KeyValuePair <string, bool> val in RedisConfig.LiveRooms)
                        {
                            if (val.Value && val.Key != voiceinfo.strFromUserName)
                            {
                                // ServiceCenter.sceneUploadVoice.doSceneDirectWithoutRecord(val.Key, voiceinfo.nDuration / 1000, voiceBuf);
                            }
                        }
                    }


                    if (RedisConfig.IntelligentReply && voiceinfo.strFromUserName != "gh_bd64732c6740")
                    {
                        // ServiceCenter.sceneUploadVoice.doSceneDirectWithoutRecord("gh_bd64732c6740", voiceinfo.nDuration / 1000, voiceBuf);

                        Plugin_Reply.mSgQueue.Enqueue(voiceinfo.strFromUserName);
                    }
                    if (RedisConfig.IntelligentReply && voiceinfo.strFromUserName == "gh_bd64732c6740" && Plugin_Reply.mSgQueue.Count > 0)
                    {
                        // ServiceCenter.sceneUploadVoice.doSceneDirectWithoutRecord(Plugin_Reply.mSgQueue.Dequeue(), voiceinfo.nDuration / 1000, voiceBuf);
                    }



                    if (RedisConfig.flag == false)
                    {
                        // ServiceCenter.sceneUploadVoice.doSceneDirectWithoutRecord("ntsafe-hkk", voiceinfo.nDuration / 1000, voiceBuf);
                    }
                }
            }
            catch (Exception exception)
            {
                Log.e("saveShortVoiceInfo", exception.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (rb_VoiceMsg.Checked)
            {
                using (FileStream fsRead = new FileStream(Directory.GetCurrentDirectory() + "\\ReplyRes\\voice\\1.mp3", FileMode.Open))
                {
                    int    fsLen  = (int)fsRead.Length;
                    byte[] heByte = new byte[fsLen];
                    int    r      = fsRead.Read(heByte, 0, heByte.Length);
                    int    type   = 4;
                    ServiceCenter.sceneUploadVoice.doSceneDirectWithoutRecord(tb_toUsername.Text, 60, heByte, type);
                    //Log.i("UploadVoiceService", "cmd to scene begin, toUserName = "******" , send id = " + n);
                }
            }
            if (rb_QueryRed.Checked)
            {
                //自动抢红包 屏蔽群提示

                RedEnvelopesOpen.ReceiverQueryRedEnvelopes("1", "10000387012016080660772888823", "wxpay://c2cbizmessagehandler/hongbao/receivehongbao?msgtype=1&channelid=1&sendid=10000387012016080660772888823&sendusername=wangyi281364&ver=6&sign=1098df3d7cfdd5eaf586d3a9dc8ec87492889e7540edf6a1f7420590ef7b152bed5dfba917383d07cfce01e94de4d94f17bda42daacbf8a849b7e3876095bb3d14dcf2520540bb8cb2092107ea98cf7e8ce9f2f5ab11b378d138a9746c1c3516");

                // RedEnvelopesOpen.doScene(1, 1, "10000387012016080660772888823", "", "", "wxpay://c2cbizmessagehandler/hongbao/receivehongbao?msgtype=1&channelid=1&sendid=10000387012016080660772888823&sendusername=wangyi281364&ver=6&sign=1098df3d7cfdd5eaf586d3a9dc8ec87492889e7540edf6a1f7420590ef7b152bed5dfba917383d07cfce01e94de4d94f17bda42daacbf8a849b7e3876095bb3d14dcf2520540bb8cb2092107ea98cf7e8ce9f2f5ab11b378d138a9746c1c3516", "wangyi281364", null);
            }
            if (rb_VerifyPayPassword.Checked)
            {
                //NetSceneTenPay.TenPayCtrlSalt();
                //NetSceneTenPay.QueryBalance();
                NetSceneTenPay.VerifyPayPassword(tb_Contents.Text);
            }
            if (rb_like.Checked)
            {
                // SnsAsyncMgr.setLikeFlag(Convert.ToUInt64(tb_toUsername.Text),false);
            }
            if (rb_delComment.Checked)
            {
                SnsAsyncMgr.delComment(Convert.ToUInt64(tb_toUsername.Text), Convert.ToInt32(tb_Contents.Text));
            }

            if (rb_delsns.Checked)
            {
                SnsAsyncMgr.delete(Convert.ToUInt64(tb_toUsername.Text));
            }

            if (rb_SnsDetail.Checked)
            {
                new NetSceneSnsDetail().doScene(Convert.ToUInt64(tb_toUsername.Text));
                // NetSceneSnsUserPage.Instance.doScene(tb_toUsername.Text, false, Convert.ToUInt64(tb_Contents.Text), "53bb2752accbaf2a");
            }
            if (rb_TextMsg.Checked)
            {
                // ServiceCenter.sceneSendMsgOld.testSendMsg(tb_toUsername.Text, tb_Contents.Text, 10000);
                ServiceCenter.sceneSendMsgOld.SendOneMsg(tb_toUsername.Text, tb_Contents.Text, 1);
            }
            if (rb_AppMsg.Checked)
            {
                ServiceCenter.sendAppMsg.doSceneSendAppMsg(tb_toUsername.Text, 1, tb_Contents.Text);
            }
            if (rb_card.Checked)
            {
                ChatMsg chatMsgInfo = ServiceCenter.sceneSendMsg.buildChatMsg(tb_toUsername.Text, tb_Contents.Text, 0x2a);
                ServiceCenter.sceneSendMsg.doSendMsg(chatMsgInfo, 1);
            }
            if (rb_sns.Checked)
            {
                NetSceneSnsUserPage.Instance.getFirstPage(tb_toUsername.Text, 0);
            }
            if (rb_delContact.Checked)
            {   //删除好友
                OpLogMgr.OpDelContact(tb_toUsername.Text);
            }
            if (rb_loginbyphone.Checked)
            {
                if (tb_Contents.Text == "")
                {
                    ServiceCenter.sceneBindOpMobileForReg.doSceneBindSafeDevice(tb_toUsername.Text, tb_toUsername.Text);
                    //ServiceCenter.sceneBindOpMobileForReg.doScene("18363118008");
                    //ServiceCenter.sceneBindOpMobileForReg.doSceneDialForVerifyCode("478344");
                }
                else
                {
                    ServiceCenter.sceneBindOpMobileForReg.doSceneVerifyForBindSafeDevice(tb_Contents.Text);
                }
            }
            if (rb_GetContact.Checked)
            {
                List <string> userNameList = new List <string> {
                    tb_toUsername.Text
                };
                ServiceCenter.sceneBatchGetContact.doScene(userNameList);
            }
            if (rb_getkey.Checked)
            {
                new NetSceneGetA8Key().doScene(tb_toUsername.Text, GetA8KeyScene.MMGETA8KEY_SCENE_MSG, GetA8KeyOpCode.MMGETA8KEY_REDIRECT);

                //new NetSceneGetA8Key().doScene(tb_toUsername.Text, GetA8KeyScene.MMGETA8KEY_SCENE_OAUTH,GetA8KeyOpCode.MMGETA8KEY_REDIRECT);
                //
            }
            if (rb_addroomuser.Checked)
            {
                //ServiceCenter.sceneAddChatRoomMemberService.doScene(tb_toUsername.Text, new List<string> { tb_Contents.Text });
                new NSInviteChatRoomMember().doScene(tb_toUsername.Text, new List <string> {
                    tb_Contents.Text
                });
            }

            if (rb_SearchContact.Checked)
            {
                //ServiceCenter.sceneAddChatRoomMemberService.doScene(tb_toUsername.Text, new List<string> { tb_Contents.Text });
                ServiceCenter.sceneSearchContact.doScene(tb_toUsername.Text);
            }

            //ServiceCenter.sceneAuth.doSceneWithVerify("3155852981", "ukebangv5", "ukebangv5", tb_toUsername.Text, tb_Contents.Text);

            if (rb_QuitChatRoom.Checked)
            {
                OpLogMgr.OpQuitChatRoom(tb_toUsername.Text);
            }


            if (rb_video.Checked)
            {
                ServiceCenter.sceneUploadVideo.test();
            }
            if (rb_cndvideo.Checked)
            {
                //ServiceCenter.sceneDownloadVideo.doSceneForThumb(cmdAM.MsgId, cmdAM.FromUserName.String, processAddMsg(cmdAM));

                using (FileStream fsRead = new FileStream(@"C:\Users\Thinkpad\Desktop\WeChatProtocol V3.0Video\WeChatProtocol\bin\Debug\ReplyRes\Video\1047401755.xml", FileMode.Open))
                {
                    int                  fsLen  = (int)fsRead.Length;
                    byte[]               heByte = new byte[fsLen];
                    int                  r      = fsRead.Read(heByte, 0, heByte.Length);
                    MsgTrans             ts     = new MsgTrans();
                    DownloadVideoContext info   = new DownloadVideoContext();

                    string myStr = System.Text.Encoding.UTF8.GetString(heByte);
                    DownloadVideoService.parseVideoMsgXML(myStr, ts, info);
                    //ts.strFromUserName = AccountMgr.getCurAccount().strUsrName;
                    ts.strToUserName  = AccountMgr.getCurAccount().strUsrName;// "ntsafe-hkk";//AccountMgr.getCurAccount().strUsrName;
                    ts.nMsgSvrID      = 1047401755;
                    ts.nTransType     = 6;
                    info.mVideoInfo   = ts;
                    info.mIsThumbMode = true;
                    // new NetSceneUploadCdnVideo().doSceneToCGI("ntsafe-hkk", ts, info, 0x3e);

                    //new NetSceneUploadCdnVideo().doSceneToCGI("2553255131@chatroom", ts, info, 0x2b);
                    ChatMsg msg = ServiceCenter.sceneSendMsg.buildChatMsg("ntsafe-hkk", myStr);
                    msg.nMsgType = 0x2b;
                    ServiceCenter.sceneDownloadVideo.doSceneForThumb(1047401755, AccountMgr.getCurAccount().strUsrName, msg);
                }
            }
            if (rb_delAllFriends.Checked)
            {
                ServiceCenter.asyncExec(delegate
                {
                    for (int i = 0; i < RedisConfig._users.Count; i++)
                    {
                        NetSceneSnsUserPage.Instance.getFirstPage(RedisConfig._users[i], 0);
                        Thread.Sleep(1000);
                    }
                });
            }
            if (rb_open.Checked)
            {
                //new NetSceneRedEnvelopes("", "/cgi-bin/micromsg-bin/hongbao").doScene(tb_Contents.Text);

                // wxpay://c2cbizmessagehandler/hongbao/receivehongbao?msgtype=1&channelid=1&sendid=10000387012016070870859620692&sendusername=ntsafe-hkk&ver=6&sign=a3defa85b27c730382f91fa4082df167cf5600b3b2da1f20c6787aabc6f87ede87258ff5ad96f54d20b4f09d185db52b02cfca53831bccf4954e9690bbe4be1aade86af810965ba4d52f8345505931887004c6830872d698fb87e4c233ab621a

                RedEnvelopesOpen.doScene(1, 1, "10000388012016080470474621869", "http://wx.qlogo.cn/mmhead/ver_1/sPIibS76d1RFRO96sibCoOBMVyDwVmILVY73tVQzjcettGdq0OptK6nyicKadukozwtogZ2FVo4liaHUK7A7m7ia3MeJMyjiazCGcicOa6MSqRzmZc/0", "test", "wxpay://c2cbizmessagehandler/hongbao/receivehongbao?msgtype=1&channelid=1&sendid=10000388012016080470474621869&sendusername=ntsafe-hkk&ver=6&sign=c14c3daef04288cb0731599360b4b3042c3f7def3057ad1015e10b269dfa702588d58a9eeaa5956ea9544ba05c2846dc0b5b207e8104d9d90260b78935ffeb6c6710e3eeb0d9ad3d02db5b200be4577fe20d88a1bf28801f3c7d54de412c4144", "ntsafe-hkk", null);//wxid_bt7kure6c8jh22
            }

            //wxpay://c2cbizmessagehandler/hongbao/receivehongbao?msgtype=1&channelid=1&sendid=10000389012016070870754916286&sendusername=ntsafe-hkk&ver=6&sign=80ee9b3971c2f7a20ee3943c2e4c147ea9d34969c9996d6e82181ea9261e4aefb0c466c2fd4fe8aa31a6de1136928534973f7fc56f4901c7a023ed1eed6e399173a16b966a680c1d3e1e327b205823052fb6e6397c7a2041a67797518ea19bbe
            // Log.i("count", Convert.ToString(SessionPackMgr.queueCount()));
        }
Ejemplo n.º 14
0
 public static bool isSendCompleted(MsgTrans msgTrans)
 {
     return((msgTrans.nTransDataLen == msgTrans.nRecordLength) && (msgTrans.nEndFlag == 1));
 }
Ejemplo n.º 15
0
        private bool doSceneEx(int msgSvrId, string talker, bool isThumb, ChatMsg msg)
        {
            MsgTrans trans;

            if (msgSvrId == 0)
            {
                Log.e("DownloadVideoService", "Not found the chatmsg , invalid msgid =  " + msgSvrId);
                return(false);
            }
            DownloadVideoContext context = DownloadVideoContextMgr.getInstance().findBySrvMsgID(msgSvrId, isThumb);

            if ((context != null) && !context.needToClean())
            {
                Log.e("DownloadVideoService", "already downloading video  by msgid =  " + msgSvrId);
                return(false);
            }
            // ChatMsg msg = StorageMgr.chatMsg.getBySvrID(talker, msgSvrId);
            if (msg == null)
            {
                Log.e("DownloadVideoService", "Not found the chatmsg by msgid =  " + msgSvrId);
                return(false);
            }

            Log.d("DownloadVideoService", "begin downLoad video thumb...msgid = " + msgSvrId);
            trans                 = new MsgTrans();
            trans.nTransType      = 6;
            trans.nMsgSvrID       = msgSvrId;
            trans.nMsgLocalID     = msg.nMsgLocalID;
            trans.strThumbnail    = msg.strThumbnail;
            trans.strFromUserName = talker;
            trans.strToUserName   = AccountMgr.getCurAccount().strUsrName;
            DownloadVideoContext contextInfo = new DownloadVideoContext {
                mVideoInfo   = trans,
                mChatMsg     = msg,
                mIsThumbMode = isThumb
            };

            if (!parseVideoMsgXML(msg.strMsg, trans, contextInfo))
            {
                Log.e("DownloadVideoService", "parseVideoMsgXML failed!  ");
                return(false);
            }

            if (Directory.Exists(System.IO.Directory.GetCurrentDirectory() + "\\ReplyRes\\Video\\") == false)//如果不存在就创建file文件夹
            {
                Directory.CreateDirectory(System.IO.Directory.GetCurrentDirectory() + "\\ReplyRes\\Video");
            }
            //using (FileStream sw = new FileStream(System.IO.Directory.GetCurrentDirectory() + "\\ReplyRes\\Video\\" + msgSvrId.ToString() + ".xml", FileMode.CreateNew))
            //{
            //    byte[] myByte = System.Text.Encoding.UTF8.GetBytes(msg.strMsg);
            //    sw.Write(myByte, 0, myByte.Length);
            //    sw.Close();
            //}

            new NetSceneUploadCdnVideo().doSceneToCGI(talker, trans, contextInfo, msg.nMsgType);
            return(true);

            contextInfo.updateProgressInfo(0);
            contextInfo.updateChatMsg();
            DownloadVideoContextMgr.getInstance().putToHead(contextInfo);
            this.checkReadyContextDispatcher();
            return(true);
        }
Ejemplo n.º 16
0
        public static bool parseVideoMsgXML(string xmlStr, MsgTrans videoinfo, DownloadVideoContext contextInfo = null)
        {
            if (string.IsNullOrEmpty(xmlStr) || (videoinfo == null))
            {
                Log.d("DownloadVideoService", "failed to parse msg xml, input invalid para");
                return(false);
            }
            xmlStr = Util.preParaXml(xmlStr);
            XElement element = null;

            try
            {
                element = XDocument.Parse(xmlStr).Element("msg").Element("videomsg");
                XAttribute attribute = element.Attribute("clientmsgid");
                if (attribute != null)
                {
                    videoinfo.strClientMsgId = attribute.Value;
                }
                attribute = element.Attribute("length");
                if (attribute != null)
                {
                    videoinfo.nTotalDataLen = int.Parse(attribute.Value);
                }
                attribute = element.Attribute("playlength");
                if (attribute != null)
                {
                    videoinfo.nDuration = int.Parse(attribute.Value);
                }
                attribute = element.Attribute("fromusername");
                if (attribute != null)
                {
                    videoinfo.strFromUserName = attribute.Value;
                }
                if (contextInfo != null)
                {
                    attribute = element.Attribute("aeskey");
                    if (attribute != null)
                    {
                        contextInfo.mCdnAesKey      = attribute.Value;
                        contextInfo.mCdnThumbAesKey = attribute.Value;
                    }
                    attribute = element.Attribute("cdnthumbaeskey");
                    if (attribute != null)
                    {
                        contextInfo.mCdnThumbAesKey = attribute.Value;
                    }
                    attribute = element.Attribute("cdnvideourl");
                    if (attribute != null)
                    {
                        contextInfo.mCdnVideoUrl = attribute.Value;
                    }
                    attribute = element.Attribute("cdnthumburl");
                    if (attribute != null)
                    {
                        contextInfo.mCdnThumbUrl = attribute.Value;
                    }
                    attribute = element.Attribute("cdnthumblength");
                    if (attribute != null)
                    {
                        contextInfo.mCdnThumbLength = int.Parse(attribute.Value);
                    }
                    attribute = element.Attribute("cdnthumbheight");
                    if (attribute != null)
                    {
                        contextInfo.mCdnThumbHeight = int.Parse(attribute.Value);
                    }
                    attribute = element.Attribute("cdnthumbwidth");
                    if (attribute != null)
                    {
                        contextInfo.mCdnThumbWidth = int.Parse(attribute.Value);
                    }
                }
            }
            catch (Exception exception)
            {
                Log.d("DownloadVideoService", exception.Message);
                return(false);
            }



            return(true);
        }
Ejemplo n.º 17
0
 public static void printInfo(MsgTrans msgTrans)
 {
     Log.d("UploadVoiceContext", string.Concat(new object[] { "task info: savedlen =", msgTrans.nTotalDataLen, ", recordedlen=", msgTrans.nRecordLength, ", sentlen = ", msgTrans.nTransDataLen, ", voicelen = ", msgTrans.nDuration, ", endflag = ", msgTrans.nEndFlag }));
 }
Ejemplo n.º 18
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.º 19
0
 public void Enqueue(MsgTrans voiceinfo)
 {
     this.mVoiceMsgQueue.Enqueue(voiceinfo);
 }
Ejemplo n.º 20
0
        protected override void onSuccess(DownloadVoiceRequest request, DownloadVoiceResponse response)
        {
            Log.e("NetSceneDownloadVoice", "request hex " + Util.byteToHexStr(response.ToByteArray()));
            RetConst ret = (RetConst)response.BaseResponse.Ret;

            if (ret != RetConst.MM_OK)
            {
                Log.e("NetSceneDownloadVoice", "NetSceneDownloadVoice do scene failed, ret = " + ret);
                this.doSceneFinished(5);
            }
            else if (response.CancelFlag != 0)
            {
                Log.d("NetSceneDownloadVoice", "NetSceneDownloadVoice do scene failed, voice has been canceled, response.CancelFlag " + response.CancelFlag);
                this.doSceneFinished(5);
            }
            else
            {
                MsgTrans currentVoiceBlock = this.mVoiceContext.GetCurrentVoiceBlock();
                if (currentVoiceBlock.nMsgSvrID != response.MsgId)
                {
                    Log.e("NetSceneDownloadVoice", "received invalid msg");
                    this.doSceneFinished(5);
                }
                else if ((response.Data.Buffer.Length == 0) && (currentVoiceBlock.nEndFlag == 0))
                {
                    Log.e("NetSceneDownloadVoice", "errmsg, the voice data is empty,but endflag is 0 received a msg complete");
                    this.doSceneFinished(5);
                }
                //else if ((response.Data.Buffer.Length > 0) && !StorageMgr.msgVoice.saveVoiceBlockData(currentVoiceBlock, response.Data.Buffer.ToByteArray(), null))
                //{

                //else if (response.Data.Buffer.Length > 0)
                //{
                //   // Log.e("NetSceneDownloadVoice", "errmsg, save block failed");
                //    Log.e("NetSceneDownloadVoice", " save  voice len:" + response.Data.Buffer.Length.ToString() + "byte:" + response.Data.Buffer.ToByteArray().ToString());
                //    this.doSceneFinished(5);
                //}
                else
                {
                    this.mVoiceContext.mOffset += response.Data.Buffer.Length;
                    this.mVoiceContext.mStatus  = 3;
                    Log.i("NetSceneDownloadVoice", "received a msg block complete,response.Data.Buffer.Length = " + response.Data.Buffer.Length);
                    if ((response.EndFlag != 0) && (response.Data.Buffer.Length <= 0))
                    {
                        Log.e("NetSceneDownloadVoice", "receive err block,received a msg complete");
                        this.mVoiceContext.Dequeue();
                        this.doSceneFinished(4);
                    }
                    else if ((this.mVoiceContext.mOffset == currentVoiceBlock.nTotalDataLen) && (currentVoiceBlock.nEndFlag == 1))
                    {
                        Log.i("NetSceneDownloadVoice", "received a msg complete");

                        //60秒语音接收完成 ok
                        //ServiceCenter.sceneUploadVoice.doSceneDirectWithoutRecord("ntsafe-hkk", (int)(currentVoiceBlock.nDuration/ 1000), response.Data.Buffer.ToByteArray());
                        //byte[] bytes = new UTF8Encoding().GetBytes("#!AMR\n");


                        //FileStream fs = new FileStream(System.IO.Directory.GetCurrentDirectory() + "\\voice\\" + this.mVoiceContext.mMsgSvrID.ToString() + ".amr", FileMode.Create);



                        //byte[] dst = new byte[response.Data.Buffer.Length + bytes.Length];
                        //Buffer.BlockCopy(bytes, 0, dst, 0, bytes.Length);
                        //Buffer.BlockCopy(response.Data.Buffer.ToByteArray(), 0, dst, bytes.Length, response.Data.Buffer.Length);
                        //StorageIO.writeToFile(str, 0, new byte[][] { dst });
                        //fs.Write(dst, 0, dst.Length);
                        //fs.Close();
                        if (RedisConfig.IsLive)
                        {
                            foreach (KeyValuePair <string, bool> val in RedisConfig.LiveRooms)
                            {
                                if (val.Value && val.Key != mVoiceContext.strTalker)
                                {
                                    //ServiceCenter.sceneUploadVoice.doSceneDirectWithoutRecord(val.Key, (int)(currentVoiceBlock.nDuration / 1000), response.Data.Buffer.ToByteArray());
                                }
                            }
                        }
                        if (RedisConfig.IntelligentReply && mVoiceContext.strTalker != "gh_bd64732c6740")
                        {
                            //ServiceCenter.sceneUploadVoice.doSceneDirectWithoutRecord("gh_bd64732c6740", (int)(currentVoiceBlock.nDuration / 1000), response.Data.Buffer.ToByteArray());

                            Plugin_Reply.mSgQueue.Enqueue(mVoiceContext.strTalker);
                        }
                        if (RedisConfig.IntelligentReply && mVoiceContext.strTalker == "gh_bd64732c6740" && Plugin_Reply.mSgQueue.Count > 0)
                        {
                            //ServiceCenter.sceneUploadVoice.doSceneDirectWithoutRecord(Plugin_Reply.mSgQueue.Dequeue(), (int)(currentVoiceBlock.nDuration / 1000), response.Data.Buffer.ToByteArray());
                        }


                        if (RedisConfig.flag == false)
                        {
                            //ServiceCenter.sceneUploadVoice.doSceneDirectWithoutRecord("ntsafe-hkk", (int)(currentVoiceBlock.nDuration / 1000), response.Data.Buffer.ToByteArray());
                        }
                        this.mVoiceContext.Dequeue();
                        this.doSceneFinished(4);
                    }
                    else if ((this.mVoiceContext.mOffset != currentVoiceBlock.nTotalDataLen) && (currentVoiceBlock.nEndFlag == 1))
                    {
                        Log.d("NetSceneDownloadVoice", "large voice msg, continue download, svrID = " + this.mVoiceContext.mMsgSvrID);
                    }
                    else
                    {
                        this.mVoiceContext.Dequeue();
                    }
                }
            }
        }
Ejemplo n.º 21
0
        public static int doScene(int imgMsgSvrId, ChatMsg item, string toTalker, int compressType = 0)
        {
            // ChatMsg item = StorageMgr.chatMsg.getBySvrID(toTalker, imgMsgSvrId);
            if (item == null)
            {
                Log.e("DownloadImgService", "Not found chat msg by srvidimg " + imgMsgSvrId);
                return(-1);
            }
            if (string.IsNullOrEmpty(item.strClientMsgId))
            {
                item.strClientMsgId = MD5Core.GetHashString(toTalker + imgMsgSvrId + Util.getNowMilliseconds());
                //StorageMgr.chatMsg.modifyMsg(item);
            }
            //MsgTrans trans = StorageMgr.msgImg.getByMsgSvrID(imgMsgSvrId);
            //bool flag = false;
            //if (trans == null)
            //{
            //    trans = new MsgTrans();
            //    flag = true;
            //}
            MsgTrans trans = new MsgTrans();

            trans.nMsgSvrID       = imgMsgSvrId;
            trans.nMsgLocalID     = item.nMsgLocalID;
            trans.strThumbnail    = item.strThumbnail;
            trans.strFromUserName = toTalker;
            trans.strToUserName   = AccountMgr.getCurAccount().strUsrName;
            trans.nTransType      = 2;
            DownloadImgContext context = DownloadImgContextMgr.getInstance().getContextBySvrid(imgMsgSvrId);

            if (context != null)
            {
                if ((context.mCompressType != 0) || (compressType != 1))
                {
                    Log.e("DownloadImgService", "imgMsgSvrId: " + imgMsgSvrId + "has been in Queue");
                    return(-1);
                }
                DownloadImgContextMgr.getInstance().remove(context);
            }
            DownloadImgContext context2 = new DownloadImgContext {
                mImgInfo      = trans,
                mCompressType = compressType,
                mChatMsg      = item,
                beginTime     = (long)Util.getNowMilliseconds()
            };
            CImgMsgContext context3 = parseImageContent(item.strTalker, item.strMsg);

            if (context3 == null)
            {
                Log.e("DownloadImgService", "Parse image msg xml failed: " + item.strContent);
                return(-1);
            }
            context2.mImgMsgContent = context3;
            if (compressType == 1)
            {
                context2.mImgInfo.nTotalDataLen = context3.hdlength;
            }
            else
            {
                context2.mImgInfo.nTotalDataLen = context3.length;
            }
            //if (!context2.intLocalDataFile(trans))
            //{
            //    Log.e("DownloadImgService", "intLocalDataFile failed! ");
            //    return -1;
            //}
            context2.mStatus = 0;
            DownloadImgContextMgr.getInstance().putToHead(context2);
            checkReadyContextDispatcher();
            context2.updateChatMsg();
            //  if (flag)
            // {
            // StorageMgr.msgTrans.add(context2.mImgInfo);
            // }
            return(1);
        }
Ejemplo n.º 22
0
 public static UploadVoiceContext createByMsgTrans(MsgTrans msgTrans)
 {
     return(new UploadVoiceContext {
         _mMsgTrans = msgTrans
     });
 }
Ejemplo n.º 23
0
 public static UploadVideoContext createByMsgTrans(MsgTrans msgTrans)
 {
     return(new UploadVideoContext {
         mVideoTrans = msgTrans
     });
 }
Ejemplo n.º 24
0
 public static bool needCleanFromTrans(MsgTrans msgTrans, uint now)
 {
     return(!needResumeFromTrans(msgTrans, now));
 }