Skip to content

Commit

Permalink
Work on MessageReassembler (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Nov 3, 2017
1 parent d285c4d commit a1b7543
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ internal async Task<IncomingMessage> ProcessAsync(CancellationToken cancellation
// FIXME
// evaluate the purpose of this reply back to the nanoFramework device, the nanoCLR doesn't seem to have to handle this. In the end it looks like this does have any real purpose and will only be wasting CPU.
await IncomingMessage.ReplyBadPacketAsync(_parent, Flags.c_BadHeader, cancellationToken);

// setup restart
_state = ReceiveState.Initialize;

return GetCompleteMessage();
}

Expand Down Expand Up @@ -225,12 +229,16 @@ internal async Task<IncomingMessage> ProcessAsync(CancellationToken cancellation
{
DebuggerEventSource.Log.WireProtocolReceiveState(_state);

// setup restart
_state = ReceiveState.Initialize;

return GetCompleteMessage();
}
else
{
// this is not the message we were waiting
// no need to wait for execution just throw it
Debug.WriteLine("-->>>");
_parent.App.ProcessMessageAsync(GetCompleteMessage(), fReply).FireAndForget();
}

Expand All @@ -252,6 +260,10 @@ internal async Task<IncomingMessage> ProcessAsync(CancellationToken cancellation
// FIXME
// evaluate the purpose of this reply back to the nanoFramework device, the nanoCLR doesn't seem to have to handle this. In the end it looks like this does have any real purpose and will only be wasting CPU.
await IncomingMessage.ReplyBadPacketAsync(_parent, Flags.c_BadPayload, cancellationToken);

// setup restart
_state = ReceiveState.Initialize;

return GetCompleteMessage();
}

Expand Down Expand Up @@ -323,7 +335,7 @@ public async Task<bool> ProcessMessage(IncomingMessage msg, bool fReply, Cancell

Request reply = null;

if (request.MatchesReply(msg))
if (request != null && request.MatchesReply(msg))
{
reply = request;

Expand Down

0 comments on commit a1b7543

Please sign in to comment.