Closed MichaelElmore1 closed 11 months ago
Sorry I didn't really have time to look at this in details. Are you guys happy with the current version or does this PR need more work? Thanks
It does need more work
https://github.com/opensensorhub/osh-core/pull/245
This PR is obsolete, and the above is the new version.
I added a TCPServerCommProvider, which allows OSH to act as a server and send/receive data from a number of clients.
The TCP and UDP comm providers only allow a single connection, and so have been using getInputStream and getOutputStream. Since a server can have many connections, I had to implement a way to serve up the input and output stream, and do so in a way that all the comm providers can get access to the input and output streams regardless of whether server or client.
Now, rather than using getInputStream and getOutputStream, you can register code to call in onConnection:
or (alt syntax)
onConnection is called whenever a connection is established. For TCP and UDP comm providers, this connection always happens in start(), so the onConnection event should be registered before the comm module is started:
In your onConnection method, you can handle getting the input and output streams the same way, regardless of whether OSH is acting as a client or server.
Please let me know if I need to make any changes, write unit tests, or anything else.