コード例 #1
0
        public void RetryFill(com.unity.mgobe.Room room)
        {
            if (this._beginFrameId == this._endFrameId && this._beginFrameId < 0)
            {
                return;
            }
            this._autoReqFrameErrTimes = 0;

            this.Fill(this._beginFrameId, this._endFrameId, room);
        }
コード例 #2
0
        private void Fill(int beginFrameId, int endFrameId, com.unity.mgobe.Room room)
        {
            if (!room.IsInRoom())
            {
                return;
            }
            Action <ResponseEvent> callback = (eve) =>
            {
                this._beginFrameId = beginFrameId;
                this._endFrameId   = endFrameId;
                if (eve.Code != ErrCode.EcOk)
                {
                    this._autoReqFrameErrTimes++;
                    if (this._autoReqFrameErrTimes <= 5)
                    {
                        this.Fill(beginFrameId, endFrameId, room);
                    }
                    else
                    {
                        room.OnAutoRequestFrameError?.Invoke(new BroadcastEvent(eve, ""));
                    }
                }
                else
                {
                    this._beginFrameId = -1;
                    this._endFrameId   = -1;

                    this._autoReqFrameErrTimes = 0;
                    var rsp   = (RequestFrameRsp)eve.Data;
                    var cache = new FrameCache(endFrameId);
                    foreach (var item in rsp.Frames)
                    {
                        var frame = new Frame
                        {
                            Id       = item.Id,
                            Ext      = item.Ext,
                            Time     = item.Time,
                            RoomId   = room.RoomInfo.Id,
                            IsReplay = true
                        };
                        frame.Items.AddRange(item.Items);
                        cache.Add(frame);
                    }
                    this._fillCache.Add(beginFrameId, cache);
                    this.FillSend(beginFrameId);
                }
            };
            RequestFramePara frameParam = new RequestFramePara
            {
                BeginFrameId = beginFrameId + 0,
                EndFrameId   = endFrameId + 0,
            };

            room.RequestFrame(frameParam, callback);
        }
コード例 #3
0
        public void Push(BroadcastEvent eve, com.unity.mgobe.Room room)
        {
            var bst     = (RecvFrameBst)eve.Data;
            var frameId = Convert.ToInt32(bst.Frame.Id);

            if (frameId == 1)
            {
                this.Reset(0);
            }

            this._timer.Push(frameId, SdkUtil.GetCurrentTimeMilliseconds());

            var frameIdSent = this._frameIdSent;
            var frameIdFill = this._frameIdFill;

            this._frameIdFill = frameId;

            // 不自动补帧就直接发出去
            if (!Config.IsAutoRequestFrame)
            {
                this.Send(eve);
                return;
            }

            if (frameId <= frameIdSent + 1)
            {
                this.Send(eve);
                return;
            }

            this._fillCache.Add(frameId, new FrameCache(frameId));
            this._fillCache[frameId].Add(bst.Frame);

            if (frameId > frameIdFill + 1)
            {
                this.Fill(frameIdFill + 1, frameId - 1, room);
            }
        }