This PR adds a new event that is raised when AprsIsConnection receives and successfully decodes a packet. This is different than the existing event that is raised on every single TCP message received from the server. This event fully decodes a packet and passes it to the event handler.
The goal of this change is to offload work from the client by reducing the kind of code the client will have to duplicate. Instead of all clients writing the packet decode call, this can be handled directly by the AprsIsConnection, reducing requirements on the client to simply handling the packet that is received.
This resolves #80.
Changes
Add ReceivedPacket event to ApsIsConnection and decode packets when there is a subscriber to the event.
Add testing
Updated the yield logic on the receive task to only yield when there are no new messages to receive, thus ensuring the client can work as quickly as the server sends messages
Switched to use Thread.Yield() instead of Thread.Sleep(500) to ensure the task can be picked up again whenever the scheduler is ready for it
Validation
Added a new test for the event
All tests are passing
Manual verification, see screenshots below
All successes:
Write to error output when a message decode fails:
Description
This PR adds a new event that is raised when
AprsIsConnection
receives and successfully decodes a packet. This is different than the existing event that is raised on every single TCP message received from the server. This event fully decodes a packet and passes it to the event handler.The goal of this change is to offload work from the client by reducing the kind of code the client will have to duplicate. Instead of all clients writing the packet decode call, this can be handled directly by the
AprsIsConnection
, reducing requirements on the client to simply handling the packet that is received.This resolves #80.
Changes
ReceivedPacket
event toApsIsConnection
and decode packets when there is a subscriber to the event.Thread.Yield()
instead ofThread.Sleep(500)
to ensure the task can be picked up again whenever the scheduler is ready for itValidation
All successes:![image](https://user-images.githubusercontent.com/3268813/149255328-7a122648-2ae3-4324-bd8e-80ebbb572559.png)
Write to error output when a message decode fails:![image](https://user-images.githubusercontent.com/3268813/149255408-5b26f6e7-2bc1-4b1f-9675-4561599a9d7b.png)