Esempio n. 1
0
 private void OnFrameDetached(string frameId)
 {
     if (Frames.ContainsKey(frameId))
     {
         RemoveFramesRecursively(Frames[frameId]);
     }
 }
Esempio n. 2
0
 private void OnFrameAttached(string frameId, string parentFrameId)
 {
     if (!Frames.ContainsKey(frameId) && Frames.ContainsKey(parentFrameId))
     {
         var parentFrame = Frames[parentFrameId];
         var frame       = new Frame(this, _client, parentFrame, frameId);
         Frames[frame.Id] = frame;
         FrameAttached?.Invoke(this, new FrameEventArgs(frame));
     }
 }
Esempio n. 3
0
        private void OnLifeCycleEvent(MessageEventArgs e)
        {
            if (Frames.ContainsKey(e.MessageData.frameId.ToString()))
            {
                Frame frame = Frames[e.MessageData.frameId.ToString()];

                frame.OnLifecycleEvent(e.MessageData.loaderId.ToString(), e.MessageData.name.ToString());
                LifecycleEvent?.Invoke(this, new FrameEventArgs(frame));
            }
        }
 public void MonitorPacket(int packetId, MonitorPacketDelegate deleg)
 {
     if (Frames.ContainsKey(packetId))
     {
         Frames[packetId].Add(deleg);
     }
     else
     {
         Frames.Add(packetId, new List <MonitorPacketDelegate> {
             deleg
         });
     }
 }
Esempio n. 5
0
        /// <summary>
        ///     Removes any frames of the specified type from the tag.
        /// </summary>
        /// <typeparam name="TFrame">Type of frame to remove</typeparam>
        /// <returns>True, if matching frames were removed, otherwise false.</returns>
        public bool Remove <TFrame>()
            where TFrame : Id3Frame
        {
            Type frameType = typeof(TFrame);

            if (!Frames.ContainsKey(frameType))
            {
                return(false);
            }

            Frames.Remove(frameType);
            return(true);
        }
Esempio n. 6
0
    /// <summary>
    /// Handles data received from server.
    /// </summary>
    void HandleonData(byte tag, ushort frameCount, object data)
    {
        switch ((NetworkTag)tag)
        {
        //Meta data includes connection, room initialization, and subject.
        //In the current implementation, the server automatically puts a player in a room upon connecting
        //So there is no need for NetworkTag.Meta out of the box.
        case NetworkTag.Meta:

            break;

        //Game data includes sending input to the server and receiving frames from the server
        case NetworkTag.Game:
            //Checking if we already have the frame to prevent duplicate frames
            if (Frames.ContainsKey(frameCount))
            {
                break;
            }

            //Checks if this frame is the one we're expecting
            if (frameCount == NextStepCount)
            {
                Frames.Add(frameCount, new Frame((byte[])data));
                NextStepCount++;
                ForeSight++;
                //Check how many frames in advance we have already stored
                for (ushort i = NextStepCount; i < Frames.Count; i++)
                {
                    if (Frames.ContainsKey(i))
                    {
                        NextStepCount++;
                        ForeSight++;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else if (frameCount > NextStepCount)
            {
                //If it's a future frame that we won't immediately use, store it for later
                Frames.Add(frameCount, new Frame((byte[])data));
            }
            break;
        }
    }
Esempio n. 7
0
        /// <summary>
        ///     Removes all frames of a specific type from the tag. A predicate can be optionally specified to control the frames
        ///     that are removed.
        /// </summary>
        /// <typeparam name="TFrame">Type of frame to remove.</typeparam>
        /// <param name="predicate">Optional predicate to control the frames that are removed</param>
        /// <returns>The number of frames removed.</returns>
        public int RemoveWhere <TFrame>(Func <TFrame, bool> predicate)
            where TFrame : Id3Frame
        {
            Type frameType = typeof(TFrame);

            if (!Frames.ContainsKey(frameType))
            {
                return(0);
            }

            object frameObj     = Frames[frameType];
            int    removalCount = 0;

            if (frameObj is IList list)
            {
                for (int i = list.Count - 1; i >= 0; i--)
                {
                    if (predicate((TFrame)list[i]))
                    {
                        list.RemoveAt(i);
                        removalCount++;
                    }
                }

                if (list.Count == 0)
                {
                    Frames.Remove(frameType);
                }
            }
            else
            {
                var frame = (TFrame)frameObj;
                if (predicate(frame))
                {
                    Frames.Remove(frameType);
                    removalCount++;
                }
            }

            return(removalCount);
        }
Esempio n. 8
0
 /// <summary>
 /// Gets the frame by frame ID.
 /// </summary>
 public LogLineFrameData GetFrame(int frameId)
 {
     return(Frames != null && Frames.ContainsKey(frameId) ? Frames[frameId] : null);
 }