示例#1
0
        static void CopyToBuff(ref BlockInfo buff, ref MsgHead head, byte[] src)
        {
            int start = MsgHead.Size;

            if (buff.DataCount > 0)
            {
                int index = head.CurPart * FragmentSize;
                int len   = head.PartLen;
                int all   = buff.DataCount;
                unsafe
                {
                    byte *tar = buff.Addr;
                    for (int i = 0; i < len; i++)
                    {
                        if (index >= all)
                        {
                            break;
                        }
                        tar[index] = src[start];
                        index++;
                        start++;
                    }
                }
            }
        }
示例#2
0
 void AddNew(ref MsgHead head, byte[] dat, int index)
 {
     if (head.AllPart > 1)
     {
         unsafe
         {
             SetChecked(caches[index].states.Addr, head.CurPart);
         }
     }
     CopyToBuff(ref caches[index].buff, ref head, dat);
     caches[index].rcvLen = 1;
 }
示例#3
0
        void FillMsg(ref MsgHead head, byte[] dat, int index)
        {
            bool a;

            unsafe
            {
                a = SetChecked(caches[index].states.Addr, head.CurPart);
            }
            if (a)
            {
                CopyToBuff(ref caches[index].buff, ref head, dat);
                caches[index].rcvLen++;
            }
        }
示例#4
0
        public void Success(ref MsgHead head, KcpData link)
        {
            unsafe
            {
                fixed(byte *bp = &tmp2[0])
                {
                    MsgReturn *hp = (MsgReturn *)bp;

                    hp->Type    = EnvelopeType.Success;
                    hp->MsgID   = head.MsgID;
                    hp->CurPart = head.CurPart;
                    hp->Time    = head.Time;
                }
            }
            int c = PackInt(tmp2, MsgReturn.Size, tmpBuffer);

            kcpListener.soc.SendTo(tmpBuffer, c, SocketFlags.None, link.endpPoint);
        }