private UntypedReceive WaitingForBody(IHandleEventListener el, IO.ByteString buffer, int length) { if (buffer.Count >= length) { var parts = buffer.SplitAt(length); el.Notify(new InboundPayload(ByteString.CopyFrom(parts.Item1.ToArray()))); return WaitingForPrefix(el, parts.Item2); } return message => { if (message is Tcp.Received) { var received = message as Tcp.Received; Become(WaitingForBody(el, buffer.Concat(received.Data), length)); } else HandleWrite(message); }; }