public Command(MethodBase method, ContentHeaderBase header, IMemoryOwner <byte> body, int bodySize) { Method = method; Header = header; _body = body; Body = _body?.Memory.Slice(0, bodySize) ?? s_emptyByteArray; }
public Command(MethodBase method, ContentHeaderBase header, byte[] body) { Method = method; Header = header; m_body0 = body; m_bodyN = null; }
public MethodBase ModelRpc(MethodBase method, ContentHeaderBase header, byte[] body) { SimpleBlockingRpcContinuation k = new SimpleBlockingRpcContinuation(); TransmitAndEnqueue(new Command(method, header, body), k); return(k.GetReply().Method); }
public IncomingCommand(MethodBase method, ContentHeaderBase header, ReadOnlyMemory <byte> body, byte[] rentedArray) { Method = method; Header = header; Body = body; _rentedArray = rentedArray; }
public HeaderOutboundFrame(int channel, ContentHeaderBase header, int bodyLength) : base(FrameType.FrameHeader, channel) { NetworkBinaryWriter writer = base.GetWriter(); writer.Write((ushort)header.ProtocolClassId); header.WriteTo(writer, (ulong)bodyLength); }
public Command(MethodBase method, ContentHeaderBase header, ReadOnlyMemory <byte> body, bool returnBufferOnDispose) { Method = method; Header = header; Body = body; _returnBufferOnDispose = returnBufferOnDispose; }
public void ModelSend(MethodBase method, ContentHeaderBase header, byte[] body) { if (method.HasContent) { m_flowControlBlock.WaitOne(); } m_session.Transmit(new Command(method, header, body)); }
private void Reset() { m_state = AssemblyState.ExpectingMethod; m_method = null; m_header = null; m_body = null; _offset = 0; m_remainingBodyBytes = 0; }
private void Reset() { _method = null; _header = null; _bodyBytes = null; _body = ReadOnlyMemory <byte> .Empty; _remainingBodyBytes = 0; _offset = 0; _state = AssemblyState.ExpectingMethod; }
private void Reset() { _methodBytes = ReadOnlyMemory <byte> .Empty; _rentedMethodArray = null; _commandId = default; _header = null; _bodyBytes = null; _body = ReadOnlyMemory <byte> .Empty; _remainingBodyBytes = 0; _offset = 0; _state = AssemblyState.ExpectingMethod; }
public Command HandleFrame(InboundFrame f) { switch (m_state) { case AssemblyState.ExpectingMethod: if (!f.IsMethod()) { throw new UnexpectedFrameException(f); } m_method = m_protocol.DecodeMethodFrom(f.Payload); m_state = m_method.HasContent ? AssemblyState.ExpectingContentHeader : AssemblyState.Complete; return(CompletedCommand()); case AssemblyState.ExpectingContentHeader: if (!f.IsHeader()) { throw new UnexpectedFrameException(f); } m_header = m_protocol.DecodeContentHeaderFrom(NetworkOrderDeserializer.ReadUInt16(f.Payload)); ulong totalBodyBytes = m_header.ReadFrom(f.Payload.Slice(2)); if (totalBodyBytes > MaxArrayOfBytesSize) { throw new UnexpectedFrameException(f); } m_remainingBodyBytes = (int)totalBodyBytes; m_body = MemoryPool <byte> .Shared.Rent(m_remainingBodyBytes); UpdateContentBodyState(); return(CompletedCommand()); case AssemblyState.ExpectingContentBody: if (!f.IsBody()) { throw new UnexpectedFrameException(f); } if (f.Payload.Length > m_remainingBodyBytes) { throw new MalformedFrameException($"Overlong content body received - {m_remainingBodyBytes} bytes remaining, {f.Payload.Length} bytes received"); } f.Payload.CopyTo(m_body.Memory.Slice(_offset)); m_remainingBodyBytes -= f.Payload.Length; _offset += f.Payload.Length; UpdateContentBodyState(); return(CompletedCommand()); case AssemblyState.Complete: default: return(null); } }
public Command(MethodBase method, ContentHeaderBase header, byte[] body) { Method = method; Header = header; if (body != null) { m_body = body; } else { m_body = m_emptyByteArray; } }
public Command(MethodBase method, ContentHeaderBase header, byte[] body) { Method = method; Header = header; if (body != null) { m_body = new MemoryStream(body); } else { m_body = new MemoryStream(); } }
public static int WriteTo(Span <byte> span, ushort channel, ContentHeaderBase header, int bodyLength) { const int StartClassId = StartPayload; const int StartWeight = StartPayload + 2; const int StartBodyLength = StartPayload + 4; const int StartHeaderArguments = StartPayload + 12; NetworkOrderSerializer.WriteUInt16(span.Slice(StartClassId), header.ProtocolClassId); NetworkOrderSerializer.WriteUInt16(span.Slice(StartWeight), 0); // Weight - not used NetworkOrderSerializer.WriteUInt64(span.Slice(StartBodyLength), (ulong)bodyLength); int offset = header.WritePropertiesTo(span.Slice(StartHeaderArguments)); return(WriteBaseFrame(span, FrameType.FrameHeader, channel, StartHeaderArguments - StartPayload + offset)); }
public MethodBase ModelRpc(MethodBase method, ContentHeaderBase header, byte[] body) { SimpleBlockingRpcContinuation k = new SimpleBlockingRpcContinuation(); TransmitAndEnqueue(new Command(method, header, body), k); return k.GetReply().Method; }
public void ModelSend(MethodBase method, ContentHeaderBase header, byte[] body) { if (method.HasContent) { lock (m_flowSendLock) { m_flowControlBlock.WaitOne(); m_session.Transmit(new Command(method, header, body)); } } else { m_session.Transmit(new Command(method, header, body)); } }
public Command(MethodBase method, ContentHeaderBase header, byte[] body) { Method = method; Header = header; Body = body ?? s_emptyByteArray; }
internal HeaderOutboundFrame(int channel, ContentHeaderBase header, int bodyLength) : base(FrameType.FrameHeader, channel) { _header = header; _bodyLength = bodyLength; }
public Command HandleFrame(InboundFrame f) { switch (m_state) { case AssemblyState.ExpectingMethod: { if (!f.IsMethod()) { throw new UnexpectedFrameException(f); } m_method = m_protocol.DecodeMethodFrom(f.GetReader()); m_state = m_method.HasContent ? AssemblyState.ExpectingContentHeader : AssemblyState.Complete; return(CompletedCommand()); } case AssemblyState.ExpectingContentHeader: { if (!f.IsHeader()) { throw new UnexpectedFrameException(f); } NetworkBinaryReader reader = f.GetReader(); m_header = m_protocol.DecodeContentHeaderFrom(reader); var totalBodyBytes = m_header.ReadFrom(reader); if (totalBodyBytes > MaxArrayOfBytesSize) { throw new UnexpectedFrameException(f); } m_remainingBodyBytes = (int)totalBodyBytes; m_body = new byte[m_remainingBodyBytes]; m_bodyStream = new MemoryStream(m_body, true); UpdateContentBodyState(); return(CompletedCommand()); } case AssemblyState.ExpectingContentBody: { if (!f.IsBody()) { throw new UnexpectedFrameException(f); } if (f.Payload.Length > m_remainingBodyBytes) { throw new MalformedFrameException (string.Format("Overlong content body received - {0} bytes remaining, {1} bytes received", m_remainingBodyBytes, f.Payload.Length)); } m_bodyStream.Write(f.Payload, 0, f.Payload.Length); m_remainingBodyBytes -= f.Payload.Length; UpdateContentBodyState(); return(CompletedCommand()); } case AssemblyState.Complete: default: #if NETFX_CORE Debug.WriteLine("Received frame in invalid state {0}; {1}", m_state, f); #else //Trace.Fail(string.Format("Received frame in invalid state {0}; {1}", m_state, f)); #endif return(null); } }
internal Command(MethodBase method, ContentHeaderBase header, ReadOnlyMemory <byte> body) { Method = method; Header = header; Body = body; }
public HeaderOutboundFrame(int channel, ContentHeaderBase header, int bodyLength) : base(FrameType.FrameHeader, channel) { this.header = header; this.bodyLength = bodyLength; }
public OutgoingContentCommand(MethodBase method, ContentHeaderBase header, ReadOnlyMemory <byte> body) { _method = method; _header = header; _body = body; }