GetWriter() public method

public GetWriter ( ) : RabbitMQ.Util.NetworkBinaryWriter
return RabbitMQ.Util.NetworkBinaryWriter
コード例 #1
0
        public void TransmitAsSingleFrame(int channelNumber, Connection connection)
        {
            var frame = new Frame(Constants.FrameMethod, channelNumber);
            NetworkBinaryWriter writer = frame.GetWriter();

            writer.Write((ushort)Method.ProtocolClassId);
            writer.Write((ushort)Method.ProtocolMethodId);
            var argWriter = new MethodArgumentWriter(writer);

            Method.WriteArgumentsTo(argWriter);
            argWriter.Flush();
            connection.WriteFrame(frame);
        }
コード例 #2
0
        public void TransmitAsFrameSet(int channelNumber, Connection connection)
        {
            var frame = new Frame(Constants.FrameMethod, channelNumber);
            NetworkBinaryWriter writer = frame.GetWriter();

            writer.Write((ushort)Method.ProtocolClassId);
            writer.Write((ushort)Method.ProtocolMethodId);
            var argWriter = new MethodArgumentWriter(writer);

            Method.WriteArgumentsTo(argWriter);
            argWriter.Flush();

            var frames = new List <Frame>();

            frames.Add(frame);

            if (Method.HasContent)
            {
                byte[] body = Body;

                frame  = new Frame(Constants.FrameHeader, channelNumber);
                writer = frame.GetWriter();
                writer.Write((ushort)Header.ProtocolClassId);
                Header.WriteTo(writer, (ulong)body.Length);
                frames.Add(frame);

                var frameMax       = (int)Math.Min(int.MaxValue, connection.FrameMax);
                int bodyPayloadMax = (frameMax == 0)
                    ? body.Length
                    : frameMax - EmptyFrameSize;
                for (int offset = 0; offset < body.Length; offset += bodyPayloadMax)
                {
                    int remaining = body.Length - offset;

                    frame  = new Frame(Constants.FrameBody, channelNumber);
                    writer = frame.GetWriter();
                    writer.Write(body, offset,
                                 (remaining < bodyPayloadMax) ? remaining : bodyPayloadMax);
                    frames.Add(frame);
                }
            }

            connection.WriteFrameSet(frames);
        }
コード例 #3
0
ファイル: Command.cs プロジェクト: pmq20/mono_forked
        public void Transmit(int channelNumber, ConnectionBase connection)
        {
            Frame frame = new Frame(CommonFraming.Constants.FrameMethod, channelNumber);
            NetworkBinaryWriter writer = frame.GetWriter();

            writer.Write((ushort)m_method.ProtocolClassId);
            writer.Write((ushort)m_method.ProtocolMethodId);
            MethodArgumentWriter argWriter = new MethodArgumentWriter(writer);

            m_method.WriteArgumentsTo(argWriter);
            argWriter.Flush();
            connection.WriteFrame(frame);

            if (m_method.HasContent)
            {
                byte[] body = Body;

                frame  = new Frame(CommonFraming.Constants.FrameHeader, channelNumber);
                writer = frame.GetWriter();
                writer.Write((ushort)m_header.ProtocolClassId);
                m_header.WriteTo(writer, (ulong)body.Length);
                connection.WriteFrame(frame);

                int frameMax       = (int)Math.Min(int.MaxValue, connection.FrameMax);
                int bodyPayloadMax = (frameMax == 0)
                    ? body.Length
                    : frameMax - EmptyContentBodyFrameSize;
                for (int offset = 0; offset < body.Length; offset += bodyPayloadMax)
                {
                    int remaining = body.Length - offset;

                    frame  = new Frame(CommonFraming.Constants.FrameBody, channelNumber);
                    writer = frame.GetWriter();
                    writer.Write(body, offset,
                                 (remaining < bodyPayloadMax) ? remaining : bodyPayloadMax);
                    connection.WriteFrame(frame);
                }
            }
        }
コード例 #4
0
        public void Transmit(int channelNumber, ConnectionBase connection)
        {
            Frame frame = new Frame(CommonFraming.Constants.FrameMethod, channelNumber);
            NetworkBinaryWriter writer = frame.GetWriter();
            writer.Write((ushort) m_method.ProtocolClassId);
            writer.Write((ushort) m_method.ProtocolMethodId);
            MethodArgumentWriter argWriter = new MethodArgumentWriter(writer);
            m_method.WriteArgumentsTo(argWriter);
            argWriter.Flush();
            connection.WriteFrame(frame);

            if (m_method.HasContent) {
                byte[] body = Body;

                frame = new Frame(CommonFraming.Constants.FrameHeader, channelNumber);
                writer = frame.GetWriter();
                writer.Write((ushort) m_header.ProtocolClassId);
                m_header.WriteTo(writer, (ulong) body.Length);
                connection.WriteFrame(frame);

                int frameMax = (int) Math.Min(int.MaxValue, connection.FrameMax);
                int bodyPayloadMax = (frameMax == 0)
                    ? body.Length
                    : frameMax - EmptyFrameSize;
                for (int offset = 0; offset < body.Length; offset += bodyPayloadMax) {
                    int remaining = body.Length - offset;

                    frame = new Frame(CommonFraming.Constants.FrameBody, channelNumber);
                    writer = frame.GetWriter();
                    writer.Write(body, offset,
                                 (remaining < bodyPayloadMax) ? remaining : bodyPayloadMax);
                    connection.WriteFrame(frame);
                }
            }
        }
コード例 #5
0
 public void TransmitAsSingleFrame(int channelNumber, Connection connection)
 {
     var frame = new Frame(Constants.FrameMethod, channelNumber);
     NetworkBinaryWriter writer = frame.GetWriter();
     writer.Write((ushort)Method.ProtocolClassId);
     writer.Write((ushort)Method.ProtocolMethodId);
     var argWriter = new MethodArgumentWriter(writer);
     Method.WriteArgumentsTo(argWriter);
     argWriter.Flush();
     connection.WriteFrame(frame);
 }