コード例 #1
0
ファイル: MeshEvent.cs プロジェクト: toomasz/emitter
        /// <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);
        }
コード例 #2
0
ファイル: WebSocketPong.cs プロジェクト: toomasz/emitter
        /// <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);
        }
コード例 #3
0
ファイル: MeshFrame.cs プロジェクト: toomasz/emitter
        /// <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);
        }
コード例 #4
0
 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());
     }
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #7
0
ファイル: MeshGossip.cs プロジェクト: toomasz/emitter
 /// <summary>
 /// Acquires a <see cref="MeshGossip"/> instance.
 /// </summary>
 public static new MeshGossip Acquire()
 {
     return(Pool.Acquire());
 }
コード例 #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());
 }