Types
AlreadyExpectingConnectionError = object of LPError
- Source Edit
ConnectionSlot = object
- Source Edit
ConnEvent = object case kind*: ConnEventKind of ConnEventKind.Connected: incoming*: bool else: nil
- Source Edit
ConnEventHandler = proc (peerId: PeerId; event: ConnEvent): Future[void] {. ...gcsafe, async: (...raises: [CancelledError]).}
- Source Edit
ConnEventKind {.pure.} = enum Connected, Disconnected
- Source Edit
ConnManager = ref object of RootObj inSema*: AsyncSemaphore outSema*: AsyncSemaphore expectedConnectionsOverLimit*: Table[(PeerId, Direction), Future[Muxer]] peerStore*: PeerStore
- Source Edit
PeerEvent = object case kind*: PeerEventKind of PeerEventKind.Joined, PeerEventKind.Identified: initiator*: bool else: nil
- Source Edit
PeerEventHandler = proc (peerId: PeerId; event: PeerEvent): Future[void] {. ...gcsafe, async: (...raises: [CancelledError]).}
- Source Edit
PeerEventKind {.pure.} = enum Left, Joined, Identified
- Source Edit
TooManyConnectionsError = object of LPError
- Source Edit
Procs
proc addConnEventHandler(c: ConnManager; handler: ConnEventHandler; kind: ConnEventKind) {....raises: [], tags: [], forbids: [].}
- Add peer event handler - handlers must not raise exceptions! Source Edit
proc addPeerEventHandler(c: ConnManager; handler: PeerEventHandler; kind: PeerEventKind) {....raises: [], tags: [], forbids: [].}
- Add peer event handler - handlers must not raise exceptions! Source Edit
proc close(c: ConnManager): InternalRaisesFuture[void, (CancelledError,)] {. ...stackTrace: false, raises: [], gcsafe, raises: [], tags: [RootEffect], forbids: [].}
- cleanup resources for the connection manager Source Edit
proc connCount(c: ConnManager; peerId: PeerId): int {....raises: [], tags: [], forbids: [].}
- Source Edit
proc connectedPeers(c: ConnManager; dir: Direction): seq[PeerId] {....raises: [], tags: [], forbids: [].}
- Source Edit
proc contains(c: ConnManager; muxer: Muxer): bool {....raises: [], tags: [], forbids: [].}
- checks if a muxer is being tracked by the connection manager Source Edit
proc contains(c: ConnManager; peerId: PeerId): bool {....raises: [], tags: [], forbids: [].}
- Source Edit
proc dropPeer(c: ConnManager; peerId: PeerId): InternalRaisesFuture[void, (CancelledError,)] {....stackTrace: false, raises: [], gcsafe, raises: [], tags: [RootEffect], forbids: [].}
- drop connections and cleanup resources for peer Source Edit
proc expectConnection(c: ConnManager; p: PeerId; dir: Direction): InternalRaisesFuture[ Muxer, (AlreadyExpectingConnectionError, CancelledError)] {. ...stackTrace: false, raises: [], gcsafe, raises: [], tags: [RootEffect], forbids: [].}
- Wait for a peer to connect to us. This will bypass the MaxConnectionsPerPeer Source Edit
proc getConnections(c: ConnManager): Table[PeerId, seq[Muxer]] {....raises: [], tags: [], forbids: [].}
- Source Edit
proc getIncomingSlot(c: ConnManager): InternalRaisesFuture[ConnectionSlot, (CancelledError,)] {....stackTrace: false, raises: [], gcsafe, raises: [], tags: [RootEffect], forbids: [].}
- Source Edit
proc getOutgoingSlot(c: ConnManager; forceDial = false): ConnectionSlot {. ...raises: [TooManyConnectionsError], raises: [], tags: [], forbids: [].}
- Source Edit
proc getStream(c: ConnManager; muxer: Muxer): InternalRaisesFuture[Connection, (LPStreamError, MuxerError, CancelledError)] {....stackTrace: false, raises: [], gcsafe, raises: [], tags: [RootEffect], forbids: [].}
- get a muxed stream for the passed muxer Source Edit
proc getStream(c: ConnManager; peerId: PeerId): InternalRaisesFuture[Connection, (LPStreamError, MuxerError, CancelledError)] {....stackTrace: false, raises: [], gcsafe, raises: [], tags: [RootEffect], forbids: [].}
- get a muxed stream for the passed peer from any connection Source Edit
proc getStream(c: ConnManager; peerId: PeerId; dir: Direction): InternalRaisesFuture[ Connection, (LPStreamError, MuxerError, CancelledError)] {. ...stackTrace: false, raises: [], gcsafe, raises: [], tags: [RootEffect], forbids: [].}
- get a muxed stream for the passed peer from a connection with dir Source Edit
proc new(C: type ConnManager; maxConnsPerPeer = MaxConnectionsPerPeer; maxConnections = MaxConnections; maxIn = -1; maxOut = -1): ConnManager {. ...raises: [].}
- Source Edit
proc release(cs: ConnectionSlot) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc removeConnEventHandler(c: ConnManager; handler: ConnEventHandler; kind: ConnEventKind) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc removePeerEventHandler(c: ConnManager; handler: PeerEventHandler; kind: PeerEventKind) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc selectMuxer(c: ConnManager; peerId: PeerId): Muxer {....raises: [], tags: [], forbids: [].}
- Select a connection for the provided giving priority to outgoing connections Source Edit
proc selectMuxer(c: ConnManager; peerId: PeerId; dir: Direction): Muxer {. ...raises: [], tags: [], forbids: [].}
- Select a connection for the provided peer and direction Source Edit
proc slotsAvailable(c: ConnManager; dir: Direction): int {....raises: [], tags: [], forbids: [].}
- Source Edit
proc storeMuxer(c: ConnManager; muxer: Muxer) {....raises: [LPError], raises: [], tags: [WriteIOEffect, RootEffect], forbids: [].}
- store the connection and muxer Source Edit
proc trackConnection(cs: ConnectionSlot; conn: Connection) {....raises: [], tags: [RootEffect], forbids: [].}
- Source Edit
proc trackMuxer(cs: ConnectionSlot; mux: Muxer) {....raises: [], tags: [RootEffect], forbids: [].}
- Source Edit
proc triggerConnEvent(c: ConnManager; peerId: PeerId; event: ConnEvent): InternalRaisesFuture[ void, (CancelledError,)] {....stackTrace: false, raises: [], gcsafe, raises: [], tags: [RootEffect], forbids: [].}
- Source Edit
proc triggerPeerEvents(c: ConnManager; peerId: PeerId; event: PeerEvent): InternalRaisesFuture[ void, (CancelledError,)] {....stackTrace: false, raises: [], gcsafe, raises: [], tags: [RootEffect], forbids: [].}
- Source Edit