Exemplo n.º 1
0
        /// <summary>
        /// Processes the packet within the context. Returns true whether the packet was processed or throttled.
        /// </summary>
        /// <param name="channel">The through which the packet is coming/going out.</param>
        /// <param name="context">The packet context for this operation.</param>
        /// <returns>True whether the packet was processed or throttled, false otherwise.</returns>
        public static ProcessingState Process(Emitter.Connection channel, ProcessingContext context)
        {
            // It can only process StringPacket objects
            var packet = context.Packet as BytePacket;

            if (packet == null)
            {
                return(ProcessingState.Failure);
            }

            // Write the string to the buffer
            context.SwitchBuffer(
                context.BufferWrite(packet.Buffer, packet.Offset, packet.Count)
                );

            return(ProcessingState.Success);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Processes the packet within the context. Returns true whether the packet was processed or throttled.
        /// </summary>
        /// <param name="channel">The through which the packet is coming/going out.</param>
        /// <param name="context">The packet context for this operation.</param>
        /// <returns>True whether the packet was processed or throttled, false otherwise.</returns>
        public static ProcessingState Process(Emitter.Connection channel, ProcessingContext context)
        {
            // It can only process StringPacket objects
            var packet = context.Packet as StringPacket;

            if (packet == null)
            {
                return(ProcessingState.Failure);
            }

            // Get the encoding and the string
            var encoding = packet.Encoding;
            var payload  = packet.StringBuilder.ToString();

            // Write the string to the buffer
            context.SwitchBuffer(
                context.BufferWrite(encoding.GetBytes(payload))
                );

            return(ProcessingState.Success);
        }