Esempio n. 1
0
        /// <summary>
        /// Acquires a <see cref="MeshEvent"/> instance.
        /// </summary>
        /// <param name="type">The event type.</param>
        /// <param name="value">The value of the event.</param>
        /// <returns> A <see cref="MeshEvent"/> that can be sent to the remote client.</returns>
        public static MeshEvent Acquire(MeshEventType type, string value = "")
        {
            // Set the type
            var packet = Pool.Acquire();

            packet.Type  = type;
            packet.Value = value;
            return(packet);
        }
Esempio n. 2
0
        /// <summary>
        /// Acquires a <see cref="WebSocketPong"/> instance.
        /// </summary>
        /// <param name="payload">The payload to copy.</param>
        /// <returns> A <see cref="WebSocketPong"/> that can be sent to the remote client.</returns>
        public static WebSocketPong Acquire(BufferSegment payload)
        {
            var packet = Pool.Acquire();

            packet.Buffer = payload.AsArray();
            return(packet);
        }
Esempio n. 3
0
        /// <summary>
        /// Acquires a <see cref="MeshFrame"/> instance.
        /// </summary>
        /// <param name="frame">The data frame</param>
        /// <returns> A <see cref="MeshFrame"/> that can be sent to the remote client.</returns>
        public static MeshFrame Acquire(ArraySegment <byte> frame)
        {
            var packet = Pool.Acquire();

            packet.Buffer = frame;
            return(packet);
        }
 public override void PacketReceived(UdpPacket udpPacket)
 {
     try
     {
         using (Packet packet = PacketPool.Acquire())
         {
             packet.UdpPacket = udpPacket;
             packet.Frame     = packet.UdpPacket.ReadIntVB();
             if (packet.Frame > this._remoteFrameActual)
             {
                 this._remoteFrameAdjust = true;
                 this._remoteFrameActual = packet.Frame;
             }
             this._bitsSecondInAcc += packet.UdpPacket.Size;
             this._packetsReceived++;
             for (int i = 0; i < this._channels.Length; i++)
             {
                 this._channels[i].Read(packet);
             }
             this._packetStatsIn.Enqueue(packet.Stats);
         }
     }
     catch (Exception exception)
     {
         BoltLog.Exception(exception);
         ModAPI.Log.Write(exception.ToString());
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Creates an instance of a http header packet
        /// </summary>
        public static HttpHeaders Create(HttpResponse response)
        {
            HttpHeaders packet = PacketPool.Acquire() as HttpHeaders;

            HttpHeaders.CompileTo(response, packet.StringBuilder);
            return(packet);
        }
Esempio n. 6
0
        /// <summary>
        /// Acquires a <see cref="MeshHandshake"/> instance.
        /// </summary>
        public new static MeshHandshake Acquire()
        {
            // Acquires a new gossip packet
            var packet = Pool.Acquire();

            packet.Type = MeshEventType.Handshake;
            return(packet);
        }
Esempio n. 7
0
 /// <summary>
 /// Acquires a <see cref="MeshGossip"/> instance.
 /// </summary>
 public static new MeshGossip Acquire()
 {
     return(Pool.Acquire());
 }
Esempio n. 8
0
 /// <summary>
 /// Acquires a <see cref="MeshEmitterEvent"/> instance.
 /// </summary>
 /// <param name="nodes">The list of nodes to populate the gossip packet with.</param>
 public static new MeshEmitterEvent Acquire()
 {
     // Acquires a new emitter event packet
     return(Pool.Acquire());
 }