Whether this connection is direct or, for example, is via a relay
Outbound connections are opened by the local node, inbound streams are opened by the remote
Optional
encryptionThe encryption protocol negotiated for this connection
The unique identifier for this connection
Optional
limitsIf present, this connection has limits applied to it, perhaps by an intermediate relay. Once the limits have been reached the connection will be closed by the relay.
The connection logger, used to log connection-specific information
Optional
multiplexerThe multiplexer negotiated for this connection
The address of the remote end of the connection
The id of the peer at the remote end of the connection
Optional
rttThe time in milliseconds it takes to make a round trip to the remote peer.
This is updated periodically by the connection monitor.
The current status of the connection
A list of open streams on this connection
When stream life cycle events occurred
Immediately close the connection. Any data queued to be sent or read will be discarded.
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
Optional
options: boolean | AddEventListenerOptionsGracefully close the connection. The returned promise will resolve when all queued data has been written to the underlying transport. Any unread data will still be emitted as a 'message' event.
Optional
options: AbortOptionsDispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
Create a new stream on this connection and negotiate one of the passed protocols
Optional
options: NewStreamOptionsRemoves the event listener in target's event listener list with the same type, callback, and options.
Optional
listener: null | EventHandler<Omit<MessageStreamEvents, "drain" | "message">[K]>Optional
options: boolean | EventListenerOptionsRemoves the event listener in target's event listener list with the same type, callback, and options.
Optional
listener: EventHandler<Event>Optional
options: boolean | EventListenerOptions
A Connection is a high-level representation of a connection to a remote peer that may have been secured by encryption and multiplexed, depending on the configuration of the nodes between which the connection is made.