예제 #1
0
 public void PostSend()
 {
     if (mStaus != PEER_STATUS.CONNECTED)
     {
         return;
     }
     if (null != mClient && mClient.Connected && mClient.GetStream().CanWrite)
     {
         if (null == mSendAsy)
         {
             if (mSendBuff.Count > 0)
             {
                 SendArg arg = mSendBuff.Dequeue();
                 using (MemoryStream ms = new MemoryStream())
                 {
                     byte[] opBs = BitConverter.GetBytes(arg.opCode);
                     ms.Write(opBs, 0, opBs.Length);
                     byte[] lenBs = BitConverter.GetBytes((uint)arg.stream.Length);
                     ms.Write(lenBs, 0, lenBs.Length);
                     ms.Write(arg.stream, 0, arg.stream.Length);
                     PostSend(ms.ToArray());
                 }
             }
         }
     }
 }
예제 #2
0
    public void SendMsg(uint opCode, byte[] stream)
    {
        SendArg arg = new SendArg();

        arg.opCode = opCode;
        arg.stream = stream;
        mSendBuff.Enqueue(arg);
    }
        public static async Task <long> Send(this IServiceProvider sp)
        {
            var ds     = sp.Resolve <ISendProductService>();
            var sendid = await sp.GetSendProvides();

            var sendarg = new SendArg {
                SendId = sendid, LogisticsImgId = "ms-qwqeqweqweqwe", LogisticsNum = "123456789"
            };
            await ds.Send(sendarg);

            var sendproductInfo = await ds.GetSendProductInfo(sendid);

            Assert.IsTrue(sendproductInfo != null);
            Assert.IsTrue(sendproductInfo.ProductName.HasContent());
            Assert.IsTrue(sendproductInfo.SendNum > 0);
            Assert.IsTrue(sendproductInfo.ProductUnit.HasContent());
            return(sendproductInfo.SendId);
        }
        public static async Task <long> Recv(this IServiceProvider sp)
        {
            var ds = sp.Resolve <ISendProductService>();
            ObjectKey <long> product = await CreateProduct(sp);

            (long applyId, UserInfo user)app = await CreateNewApply(sp, 10, product);

            (long provideId, UserInfo user)pro = await CreateNewProvide(sp, 10, product);

            await CreateNewPairRecord(sp);

            var sendids = new QueryResult <SendProductItem>();
            await sp.UserSignin(pro.user.Account, pro.user.Password);

            await sp.WithScope(async isp =>
            {
                sendids = await isp.Resolve <ISendProductService>().QuerySendProductInfo(new MemberSendProductQueryArg {
                    QueryMode = Services.Products.Front.QueryMode.发货人发货单
                });
            });

            var sendarg = new SendArg {
                SendId = sendids.Items.FirstOrDefault().SendId, LogisticsImgId = "ms-qwqeqweqweqwe", LogisticsNum = "123456789"
            };
            await ds.Send(sendarg);

            await sp.UserSignin(app.user.Account, app.user.Password);

            await ds.Recv(sendids.Items.FirstOrDefault().SendId);

            var sendproductInfo = await ds.GetSendProductInfo(sendids.Items.FirstOrDefault().SendId);

            Assert.IsTrue(sendproductInfo != null);
            Assert.IsTrue(sendproductInfo.ProductName.HasContent());
            Assert.IsTrue(sendproductInfo.SendNum > 0);
            Assert.IsTrue(sendproductInfo.ProductUnit.HasContent());
            return(sendproductInfo.SendId);
        }