diff --git a/transport-nethernet/src/main/java/dev/kastle/netty/channel/nethernet/NetherNetChildChannel.java b/transport-nethernet/src/main/java/dev/kastle/netty/channel/nethernet/NetherNetChildChannel.java index afc2e17..28c2467 100644 --- a/transport-nethernet/src/main/java/dev/kastle/netty/channel/nethernet/NetherNetChildChannel.java +++ b/transport-nethernet/src/main/java/dev/kastle/netty/channel/nethernet/NetherNetChildChannel.java @@ -3,12 +3,26 @@ import dev.kastle.netty.channel.nethernet.config.DefaultNetherChannelConfig; import io.netty.channel.Channel; import io.netty.channel.ChannelPromise; +import io.netty.util.AttributeKey; import tel.schich.libdatachannel.PeerConnection; import java.net.InetSocketAddress; import java.net.SocketAddress; public class NetherNetChildChannel extends NetherNetChannel { + + /** + * The signaling connection ID this channel was accepted for. + *

+ * A child arrives on the server pipeline carrying nothing that ties it back to the offer that + * produced it, and arrival order does not follow the order answers were produced in. Signaling + * implementations already hold per connection ID state, since that is the key + * {@code setSignalHandler} and {@code removeSignalHandler} use, so exposing it here lets them + * attribute a channel without reaching into internals. + */ + public static final AttributeKey CONNECTION_ID = + AttributeKey.valueOf(NetherNetChildChannel.class, "connectionId"); + public NetherNetChildChannel(Channel parent, PeerConnection peerConnection, InetSocketAddress remote, InetSocketAddress local) { super(parent, remote, local); this.peerConnection = peerConnection; diff --git a/transport-nethernet/src/main/java/dev/kastle/netty/channel/nethernet/NetherNetServerChannel.java b/transport-nethernet/src/main/java/dev/kastle/netty/channel/nethernet/NetherNetServerChannel.java index 117a5a5..8578752 100644 --- a/transport-nethernet/src/main/java/dev/kastle/netty/channel/nethernet/NetherNetServerChannel.java +++ b/transport-nethernet/src/main/java/dev/kastle/netty/channel/nethernet/NetherNetServerChannel.java @@ -106,6 +106,7 @@ public void acceptConnection(long connectionId, String offerSdp, String remoteNe observer.setPeerConnection(pc); NetherNetChildChannel child = new NetherNetChildChannel(this, pc, new InetSocketAddress(0), localAddress); + child.attr(NetherNetChildChannel.CONNECTION_ID).set(connectionId); observer.setChildChannel(child); child.closeFuture().addListener(future -> signaling.removeSignalHandler(connectionId));