Exemplo n.º 1
0
        /// <summary>
        /// Used to send protocol packets to the peer.
        /// </summary>
        /// <param name="packet"></param>
        /// <returns></returns>
        internal bool Send(Packet packet)
        {
            // Encode the packet
            byte[] data = packet.Encode();

            // Increment the connection transfer rate
            IncrementRate(data.Length);

            // If the maximum transfer rate is reached, send FLOW_CONTROL_ERROR
            if (MaximumReached())
            {
                packet = PacketCreator.CreateConnectionClosePacket(Infrastructure.ErrorCode.FLOW_CONTROL_ERROR, 0x00, ErrorConstants.MaxDataTransfer);

                TerminateConnection();
            }

            // Ignore empty packets
            if (data == null || data.Length <= 0)
            {
                return(true);
            }

            bool result = _pwt.SendPacket(packet);

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Used to send protocol packets to the peer.
        /// </summary>
        /// <param name="packet"></param>
        /// <returns></returns>
        internal bool Send(Packet packet)
        {
            // Encode the packet
            var data = packet.Encode();

            // Increment the connection transfer rate
            IncrementRate(data.Length);

            // If the maximum transfer rate is reached, send FLOW_CONTROL_ERROR
            if (MaximumReached())
            {
                packet = PacketCreator.CreateConnectionClosePacket(ErrorCode.FLOW_CONTROL_ERROR,
                                                                   "Maximum data transfer reached.");

                TerminateConnection();
            }

            // Ignore empty packets
            if (data.Length <= 0)
            {
                return(true);
            }

            var result = _pwt.SendPacket(packet);

            return(result);
        }
Exemplo n.º 3
0
        internal void SendMaximumStreamReachedError()
        {
            var packet = PacketCreator.CreateConnectionClosePacket(ErrorCode.STREAM_LIMIT_ERROR,
                                                                   "Maximum number of streams reached.");

            Send(packet);
        }
Exemplo n.º 4
0
        internal void SendMaximumStreamReachedError()
        {
            ShortHeaderPacket packet = PacketCreator.CreateConnectionClosePacket(Infrastructure.ErrorCode.STREAM_LIMIT_ERROR, 0x00, ErrorConstants.MaxNumberOfStreams);

            Send(packet);
        }
Exemplo n.º 5
0
        internal void SendMaximumStreamReachedError()
        {
            ShortHeaderPacket packet = PacketCreator.CreateConnectionClosePacket(Infrastructure.ErrorCode.STREAM_LIMIT_ERROR, "Maximum number of streams reached.");

            Context.Send(packet);
        }