Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* 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<Long> CONNECTION_ID =
AttributeKey.valueOf(NetherNetChildChannel.class, "connectionId");

public NetherNetChildChannel(Channel parent, PeerConnection peerConnection, InetSocketAddress remote, InetSocketAddress local) {
super(parent, remote, local);
this.peerConnection = peerConnection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down