Exemplo n.º 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++;
                    }
                }
            }
        }
Exemplo n.º 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;
 }
Exemplo n.º 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++;
            }
        }
Exemplo n.º 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);
        }