WebRtcConn class

A libp2p connection over an established WebRTC peer connection. Streams are data channels, so it is secure (DTLS, bound to the peer IDs by the authenticated signaling) and multiplexed without an upgrade: the swarm adopts it as an UpgradedTransportConn.

Implemented types
  • Conn

Constructors

WebRtcConn({required RtcPeerConnection peerConnection, required PeerId localPeer, required PeerId remotePeer, PublicKey? remotePublicKey, required MultiAddr localMultiaddr, required MultiAddr remoteMultiaddr, required Direction direction})

Properties

direction → Direction
final
done → Future<void>
Completes when the connection has closed.
no setter
hashCode → int
The hash code for this object.
no setterinherited
id → String
ID returns an identifier that uniquely identifies this Conn within this host, during this run. Connection IDs may repeat across restarts.
final
isClosed → bool
IsClosed returns whether a connection is fully closed, so it can be garbage collected.
no setteroverride
localMultiaddr → MultiAddr
LocalMultiaddr returns the local Multiaddr associated with this connection
final
localPeer → PeerId
LocalPeer returns our peer ID
final
remoteAddress → String?
ip:port of the selected remote ICE candidate.
no setter
remoteMultiaddr → MultiAddr
RemoteMultiaddr returns the remote Multiaddr associated with this connection
final
remotePeer → PeerId
RemotePeer returns the peer ID of the remote peer.
final
remotePublicKey → Future<PublicKey?>
RemotePublicKey returns the public key of the remote peer.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scope → ConnScope
Scope returns the user view of this connection's resource scope
no setteroverride
selectedCandidatePair → ({String local, String remote})?
The selected ICE candidate pair; typ relay means TURN carries it.
no setter
socket → Socket
no setteroverride
stat → ConnStats
Stat stores metadata pertaining to this conn.
no setteroverride
state → ConnState
ConnState returns information about the connection state.
no setteroverride
streams → Future<List<P2PStream>>
GetStreams returns all open streams over this conn.
no setteroverride

Methods

acceptStream() → Future<MuxedStream>
Accepts a stream opened by the other side.
override
close() → Future<void>
Closes the connection
override
newProtocolStream(List<ProtocolID> protocols) → Future<WebRtcStream>
Opens a stream and selects the first of protocols the remote speaks.
newStream(Context context) → Future<P2PStream>
NewStream constructs a new Stream over this conn.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyActivity() → void
Notifies that activity has occurred on this transport connection, potentially due to activity on a multiplexed stream over it. This can be used by multiplexers to inform the connection manager.
override
openStream(Context context) → Future<MuxedStream>
Creates a new stream.
override
read([int? length]) → Future<Uint8List>
Reads data from the connection. If length is provided, reads exactly that many bytes. Otherwise, reads whatever is available.
override
serveStreams(ProtocolSwitch mux) → Future<void>
Answers inbound streams with mux's protocol handlers (e.g. a host's mux), as the swarm does for its connections.
setReadTimeout(Duration timeout) → void
Sets a timeout for read operations.
override
setWriteTimeout(Duration timeout) → void
Sets a timeout for write operations.
override
toString() → String
A string representation of this object.
override
write(Uint8List data) → Future<void>
Writes data to the connection.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited