Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor transport-level code in preparation for TCP support #47

Closed
wants to merge 9 commits into from

Conversation

daveyarwood
Copy link
Collaborator

Background

See my comment here: #12 (comment)

To summarize, the current implementation of JavaOSC is UDP only, and there is a lot of transport-level code (all UDP-specific) in OSCPortIn and OSCPortOut.

I plan to implement TCP support soon, and I want for users to be able to continue to use the same public API, with only the small additional step of setting the network protocol to TCP, something like this:

new OSCPortInBuilder().setPort(12345).setNetworkProtocol(TCP).build();

As a first step towards that, this PR refactors / reorganizes the parts of the codebase that have to do with transport. The next step will be to simply add a TCPTransport class and OSCPort{In,Out}Builder methods to allow the user to specify the network protocol.

Summary of changes

  • BREAKING Move higher-level transport.udp.OSCPort* classes up a level to transport.OSCPort*.

    • Most of the code in these classes has nothing to do with UDP transport specifically, and is more about the transport of OSC messages at a higher level.
  • Added a Transport interface that captures the low level implementation details.

  • Moved the current UDP transport implementation into UDPTransport, which implements Transport.

  • Adjusted the toString implementations of OSCPort et al to include information about the Transport.

  • OSCParseExceptions now include the data we attempted to parse

    • see e2b9daf
    • Allows the higher level OSCPortIn class to handle the data without needing to reach down into the transport implementation.

Feedback welcome! 🙂

There is a bunch of transport-agnostic logic in osc.transport.udp that should be
shared with the upcoming TCP implementation.

The plan after this is to move UDP-specific things back down into
osc.transport.udp. Then, implement tho corresponding TCP-specific bits in
transport.tcp.
The data (a ByteBuffer) is an implementation detail of the transport. The higher
level API is only concerned with sending and receiving OSCPackets, and doesn't
need to worry about the underlying data unless something goes wrong.
I decided to remove some of the getter methods from OSCPort/OSCPortIn/OSCPortOut
that concern themselves with transport-level implementation details. This
resulted in compiler errors in the testPorts test case, as getRemoteAddress no
longer exists.

I thought about this, and I think that removing getRemoteAddress makes sense in
the context of real world usage. I don't think it makes sense to keep it just to
facilitate having these tests, which are only testing that the default values we
specified are the values you get when you don't provide a value.

I'm open to feedback on this - happy to add this back if needed!
@daveyarwood daveyarwood mentioned this pull request Jan 17, 2020
@daveyarwood
Copy link
Collaborator Author

Closing this in favor of #52, which includes these commits and many more!

@daveyarwood daveyarwood deleted the refactor-transport branch January 17, 2020 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant