Beispiel #1
0
 public int Dequeue(out int k, out NetFrame frame)
 {
     if (_sorteddic.ContainsKey(_k))
     {
         frame = _sorteddic[_k];
         _k++;
         k = _k;
         return(1);
     }
     k     = _k;
     frame = null;
     return(0);
 }
Beispiel #2
0
        public override void OnUdpRecv(byte[] data, int start, int len)
        {
            base.OnUdpRecv(data, start, len);
            int protocol;
            int offset = NetUnpack.Unpackli(data, 0, out protocol);

            if (protocol == ProtocolType.PT_DATA)
            {
                for (int i = 0; i < 3; i++)
                {
                    int k, sz;
                    offset = NetUnpack.Unpackli(data, offset, out k);
                    offset = NetUnpack.Unpackli(data, offset, out sz);
                    byte[] buffer = new byte[sz];
                    Array.Copy(data, offset, buffer, 0, sz);
                    NetFrame frame = new NetFrame();
                    frame.k      = k;
                    frame.buffer = buffer;
                    _queue.Enqueue(frame);
                }
                ExecFrame();
            }
        }
Beispiel #3
0
 public void Enqueue(NetFrame frame)
 {
     _sorteddic.Add(frame.k, frame);
 }