Esempio n. 1
0
        public void OnReceiveEvents(NetStream events, int containerFrameId)
        {
            if (!isStarted)
            {
                return;
            }
            for (int num = events.ReadFrameId(containerFrameId); num > 0; num = events.ReadFrameId(containerFrameId))
            {
                NetStream netStream = events.ReadStream(forceIndependent: true);
                if (num > lastReceivedEventFrame)
                {
                    lock (frames.framesLock)
                    {
                        frames.PushEvents(num, netStream);
                    }
                    lastReceivedEventFrame = num;
                }
                else
                {
                    netStream.Release();
                }
            }
            ReportEvenBits(events.position);
            int       writeFrameId = NetGame.instance.server.GetWriteFrameId(containerFrameId);
            NetStream netStream2   = NetGame.BeginMessage(NetMsgId.Event);

            try
            {
                netStream2.WriteNetId(netId);
                netStream2.WriteFrameId(lastReceivedEventFrame, writeFrameId);
                NetGame.instance.SendUnreliableToServer(netStream2, writeFrameId);
                ackBps.ReportBits(netStream2.position);
            }
            finally
            {
                if (netStream2 != null)
                {
                    netStream2 = netStream2.Release();
                }
            }
        }