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);
}
}
}