-
Notifications
You must be signed in to change notification settings - Fork 44
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
Allow sending and receiving messages over the same UDP socket #66
base: master
Are you sure you want to change the base?
Conversation
Hey, sorry @nsowen ! |
final Transport transport) | ||
{ | ||
if (transport == null) { | ||
throw new IllegalStateException( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would a NullPointerException
not be more appropriate?
@@ -97,6 +121,11 @@ public OSCPortInBuilder setNetworkProtocol(final NetworkProtocol protocol) { | |||
return this; | |||
} | |||
|
|||
public OSCPortInBuilder setTransport(final Transport networkTransport) { | |||
transport = networkTransport; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No must, and I see it is the same in the other methods, which is probably why you did it this way, but I' rather do this as this.transport = transport;
, vs choosing arbitrary different names for the two variables.
As said.. leaving it this way is totally fine too.
@@ -74,4 +98,9 @@ public OSCPortOutBuilder setNetworkProtocol(final NetworkProtocol protocol) { | |||
networkProtocol = protocol; | |||
return this; | |||
} | |||
|
|||
public OSCPortOutBuilder setTransport(final Transport networkTransport) { | |||
transport = networkTransport; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(... same here)
looking good! |
This extension addresses the following issue: #40
That allows bi-directional communication to my Behringer X32 console. Explanation:
With the original implementation, it was of couse possible to use the same input UDP port as the output UDP port, but unfortunately, at least on OSX, it is not possible to create two UDP sockets for sending and receiving on the same port. Therefore I extended the OSCPortOut to accept a "Transport" object in its constructor, which can be retrieved from the OSCPortIn object. Additionally, UDPTransport had to be changed to use two ByteBuffers, one for sending, the other one for receiving. Otherwise we will corrupt receive/response data on the fly. This should not make any issues, as the
var out = new OSCPortOut(new OSCSerializerAndParserBuilder(), new InetSocketAddress("x32-ip", 10023));
var in = new OSCPortIn(out.getTransport());
in.startListening();
out.send(new OSCMessage("/info"));
At least this PR works for me since for a few months now. Hope it will meet the quality standards. Please let me know!