Пример #1
0
        public ChatMsg doScene(string talkerName, string filename, byte[] origStream, int msgType = 3, ParamEx param = null)
        {
            if ((string.IsNullOrEmpty(filename) || string.IsNullOrEmpty(talkerName)) || (origStream == null))
            {
                return(null);
            }
            NetSceneUploadImage sceneInstance = new NetSceneUploadImage();

            if (param != null)
            {
                sceneInstance.mIsNeedScale = param.isNeedScale;
            }
            Log.i("UploadImgService", "==============startDoSence,mIsNeedScale = " + sceneInstance.mIsNeedScale);
            return(this.startDoSence(talkerName, filename, origStream, sceneInstance, -1, msgType, param));
        }
Пример #2
0
 private ChatMsg startDoSence(string talkerName, string filename, byte[] origStream, object sceneInstance, int nImgMsgTranId, int msgType = 3, ParamEx param = null)
 {
     if (UpLoadImgContextMgr.getInstance().countRunningContext() >= MAX_RUNNING)
     {
         Log.e("UploadImgService", "send Image scene cannot begin ,running task too much. ");
         return(null);
     }
     if ((talkerName == null) || (sceneInstance == null))
     {
         Log.e("UploadImgService", "one of the send Image scene cannot begin, param error.");
         return(null);
     }
     if ((origStream != null) && (filename != null))
     {
         UpLoadImgContext context = new UpLoadImgContext {
             talkerName = talkerName,
             filename   = filename,
             // origStream = origStream,
             //imgBUf=origStream,
             senceHandle = sceneInstance,
             mMsgType    = msgType,
             mParamEx    = param,
             beginTime   = (long)Util.getNowMilliseconds()
         };
         Log.d("UploadImgService", "begin add chatmsg");
         if (context.chatMsgInfo == null)
         {
             context.chatMsgInfo = new ChatMsg();
         }
         context.imgBUf = new byte[origStream.Length];
         Buffer.BlockCopy(origStream, 0, context.imgBUf, 0, origStream.Length);
         context.chatMsgInfo.strTalker      = talkerName;
         context.chatMsgInfo.nMsgType       = msgType;
         context.chatMsgInfo.nStatus        = 0;
         context.chatMsgInfo.nIsSender      = 1;
         context.chatMsgInfo.nCreateTime    = (long)(Util.getNowMilliseconds() / 1000.0);
         context.chatMsgInfo.strClientMsgId = MD5Core.GetHashString(talkerName + context.GetHashCode() + Util.getNowMilliseconds());
         //StorageMgr.chatMsg.addMsg(context.chatMsgInfo);
         UpLoadImgContextMgr.getInstance().putToHead(context);
         this.checkReadyContextDispatcher();
         return(context.chatMsgInfo);
     }
     if (nImgMsgTranId > 0)
     {
         Log.i("UploadImgService", "Resend image nImgMsgTranId = " + nImgMsgTranId);
         UpLoadImgContext context2 = new UpLoadImgContext();
         //context2.loadUploadImgContext(nImgMsgTranId);
         //if ((context2.imgInfo != null) && (context2.mBigImageMemoryStream != null))
         //{
         //    context2.talkerName = talkerName;
         //    context2.senceHandle = sceneInstance;
         //    context2.beginTime = (long) Util.getNowMilliseconds();
         //    UpLoadImgContextMgr.getInstance().putToHead(context2);
         //    this.checkReadyContextDispatcher();
         //    return context2.chatMsgInfo;
         //}
         Log.e("UploadImgService", "one of the send Image scene cannot begin, loadUploadImgContext from db error.");
         return(null);
     }
     Log.e("UploadImgService", "one of the send Image scene cannot begin, param error.");
     return(null);
 }