Extract the NWListener code into StateManagedListenerChannel
Motivation:
When implementing #68, a lot of code ended up being identical between TCP and UDP. Like #174, this PR paves the way to adding UDP, with very little overhead code. It moves the code that is used to represent NWListener as a Channel into its own protocol, that can then be applied to both TCP and UDP implementations.
Modifications:
Added StateManagedListenerChannel that has all the logic for handling a NWConnection as a NIO.Channel.
Made the AcceptHandler generic for use with both TCP and UDP
Result:
This makes implementing UDP much simpler, and without redundant code.
Notes
This PR works off #174 , and should therefore be viewed as a diff based on #174 to get a clean picture.
Extract the NWListener code into
StateManagedListenerChannel
Motivation:
When implementing #68, a lot of code ended up being identical between TCP and UDP. Like #174, this PR paves the way to adding UDP, with very little overhead code. It moves the code that is used to represent NWListener as a Channel into its own protocol, that can then be applied to both TCP and UDP implementations.
Modifications:
StateManagedListenerChannel
that has all the logic for handling a NWConnection as a NIO.Channel.Result:
This makes implementing UDP much simpler, and without redundant code.
Notes
This PR works off #174 , and should therefore be viewed as a diff based on #174 to get a clean picture.