Skip to content

Commit

Permalink
hoijui#50 expose the sender address on the source object
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoav Luft committed Aug 3, 2020
1 parent 6a28b74 commit de58c29
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ public class OSCPortIn extends OSCPort implements Runnable {
private final OSCSerializerAndParserBuilder parserBuilder;
private final List<OSCPacketListener> packetListeners;

public static class OSCPortInSource {
private OSCPortIn port;
private SocketAddress sender;

OSCPortInSource(OSCPortIn port, SocketAddress sender) {
this.port = port;
this.sender = sender;
}

OSCPortInSource(OSCPortIn port, DatagramChannel channel) throws IOException {
this(port, channel.getRemoteAddress());
}
}

public static OSCPacketDispatcher getDispatcher(
final List<OSCPacketListener> listeners)
{
Expand Down Expand Up @@ -199,7 +213,7 @@ public void run() {
try {
final OSCPacket oscPacket = oscChannel.read(buffer);

final OSCPacketEvent event = new OSCPacketEvent(this, oscPacket);
final OSCPacketEvent event = new OSCPacketEvent(new OSCPortInSource(this, channel), oscPacket);
for (final OSCPacketListener listener : packetListeners) {
listener.handlePacket(event);
}
Expand Down

0 comments on commit de58c29

Please sign in to comment.