Allow sending and receiving messages over the same UDP socket#66
Allow sending and receiving messages over the same UDP socket#66nsowen wants to merge 1 commit intohoijui:masterfrom
Conversation
|
Hey, sorry @nsowen ! |
| final Transport transport) | ||
| { | ||
| if (transport == null) { | ||
| throw new IllegalStateException( |
There was a problem hiding this comment.
Would a NullPointerException not be more appropriate?
| } | ||
|
|
||
| public OSCPortInBuilder setTransport(final Transport networkTransport) { | ||
| transport = networkTransport; |
There was a problem hiding this comment.
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.
| } | ||
|
|
||
| public OSCPortOutBuilder setTransport(final Transport networkTransport) { | ||
| transport = networkTransport; |
|
looking good! |
|
@nsowen any plans on updating this MR and if not, would you mind if I take over to resolve conflicts and close review comments ? Also, i think a OSCPortIn constructor similar to the one you implemented but that set the default listeners (instead of taking them as argument) might be useful |
|
If @nsowen will be active in the next few hours, all is fine, but otherwise @Britaliope please do it ! |
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!