There was no way for the library to externally expose inbound requests from other peers (in such a way that each request could be responded to).
There was no mechanism for socket events to propagate to the top level P2P instance.
There was no mechanism for handling reserved (internal) requests which could be handled internally by the P2P library.
How did I fix it?
Implemented a request/message event bubbling mechanism. Socket requests/messages bubble up the class hierarchy Socket -> Peer -> PeerPool -> P2P. There exists certain request/message types which are meant to be handled internally by the P2P module. If a class within this hierarchy sees a reserved request which is relevant to it; it will respond to the request with the appropriate data and this request will not propagate to parent instances.
What was the problem?
How did I fix it?
Implemented a request/message event bubbling mechanism. Socket requests/messages bubble up the class hierarchy
Socket -> Peer -> PeerPool -> P2P
. There exists certain request/message types which are meant to be handled internally by the P2P module. If a class within this hierarchy sees a reserved request which is relevant to it; it will respond to the request with the appropriate data and this request will not propagate to parent instances.How to test it?
Integration tests coming soon.
Review checklist