Types
ConnEvent = object case kind*: ConnEventKind of ConnEventKind.Connected: incoming*: bool else: nil
- Source Edit
ConnEventHandler = proc (peerId: PeerId; event: ConnEvent): Future[void] {. ...gcsafe, raises: [Defect].}
- Source Edit
ConnEventKind {.pure.} = enum Connected, Disconnected
- Source Edit
ConnManager = ref object of RootObj maxConnsPerPeer: int inSema*: AsyncSemaphore outSema*: AsyncSemaphore conns: Table[PeerId, HashSet[Connection]] muxed: Table[Connection, MuxerHolder] connEvents: array[ConnEventKind, OrderedSet[ConnEventHandler]] peerEvents: array[PeerEventKind, OrderedSet[PeerEventHandler]] peerStore*: PeerStore
- Source Edit
ConnProvider = proc (): Future[Connection] {....gcsafe, closure, ...raises: [Defect].}
- Source Edit
PeerEvent = object case kind*: PeerEventKind of PeerEventKind.Joined: initiator*: bool else: nil
- Source Edit
PeerEventHandler = proc (peerId: PeerId; event: PeerEvent): Future[void] {. ...gcsafe, raises: [Defect].}
- Source Edit
PeerEventKind {.pure.} = enum Left, Identified, Joined
- Source Edit
TooManyConnectionsError = object of LPError
- Source Edit
Procs
proc addConnEventHandler(c: ConnManager; handler: ConnEventHandler; kind: ConnEventKind) {....raises: [Defect], tags: [RootEffect].}
- Add peer event handler - handlers must not raise exceptions! Source Edit
proc addPeerEventHandler(c: ConnManager; handler: PeerEventHandler; kind: PeerEventKind) {....raises: [Defect], tags: [RootEffect].}
- Add peer event handler - handlers must not raise exceptions! Source Edit
proc close(c: ConnManager): Future[void] {.stackTrace: false, ...gcsafe, raises: [Defect], raises: [Defect], tags: [RootEffect].}
- cleanup resources for the connection manager Source Edit
proc connCount(c: ConnManager; peerId: PeerId): int {....raises: [Defect], tags: [].}
- Source Edit
proc contains(c: ConnManager; conn: Connection): bool {....raises: [Defect], tags: [].}
- checks if a connection is being tracked by the connection manager Source Edit
proc contains(c: ConnManager; muxer: Muxer): bool {....raises: [Defect], tags: [].}
- checks if a muxer is being tracked by the connection manager Source Edit
proc contains(c: ConnManager; peerId: PeerId): bool {....raises: [Defect], tags: [].}
- Source Edit
proc dropPeer(c: ConnManager; peerId: PeerId): Future[void] {.stackTrace: false, ...gcsafe, raises: [Defect], raises: [Defect], tags: [RootEffect].}
- drop connections and cleanup resources for peer Source Edit
proc getStream(c: ConnManager; conn: Connection): Future[Connection] {....gcsafe, stackTrace: false, ...gcsafe, raises: [Defect], raises: [Defect], tags: [RootEffect].}
- get a muxed stream for the passed connection Source Edit
proc getStream(c: ConnManager; peerId: PeerId): Future[Connection] {....gcsafe, stackTrace: false, ...gcsafe, raises: [Defect], raises: [Defect], tags: [RootEffect].}
- get a muxed stream for the passed peer from any connection Source Edit
proc getStream(c: ConnManager; peerId: PeerId; dir: Direction): Future[ Connection] {....gcsafe, stackTrace: false, ...gcsafe, raises: [Defect], raises: [Defect], tags: [RootEffect].}
- get a muxed stream for the provided peer with the given direction Source Edit
proc new(C: type ConnManager; maxConnsPerPeer = MaxConnectionsPerPeer; maxConnections = MaxConnections; maxIn = -1; maxOut = -1): ConnManager {. ...raises: [Defect].}
- Source Edit
proc removeConnEventHandler(c: ConnManager; handler: ConnEventHandler; kind: ConnEventKind) {....raises: [Defect], tags: [RootEffect].}
- Source Edit
proc removePeerEventHandler(c: ConnManager; handler: PeerEventHandler; kind: PeerEventKind) {....raises: [Defect], tags: [RootEffect].}
- Source Edit
proc selectConn(c: ConnManager; peerId: PeerId): Connection {....raises: [Defect], tags: [].}
- Select a connection for the provided giving priority to outgoing connections Source Edit
proc selectConn(c: ConnManager; peerId: PeerId; dir: Direction): Connection {. ...raises: [Defect], tags: [].}
- Select a connection for the provided peer and direction Source Edit
proc selectMuxer(c: ConnManager; conn: Connection): Muxer {....raises: [Defect], tags: [WriteIOEffect, TimeEffect].}
- select the muxer for the provided connection Source Edit
proc storeConn(c: ConnManager; conn: Connection) {....raises: [Defect, LPError], raises: [Defect], tags: [WriteIOEffect, TimeEffect, RootEffect].}
- store a connection Source Edit
proc storeMuxer(c: ConnManager; muxer: Muxer; handle: Future[void] = nil) {. ...raises: [Defect, CatchableError], raises: [Defect], tags: [RootEffect].}
- store the connection and muxer Source Edit
proc trackIncomingConn(c: ConnManager; provider: ConnProvider): Future[ Connection] {.stackTrace: false, ...gcsafe, raises: [Defect], raises: [Defect], tags: [RootEffect].}
- await for a connection slot before attempting to call the connection provider Source Edit
proc trackOutgoingConn(c: ConnManager; provider: ConnProvider; forceDial = false): Future[ Connection] {.stackTrace: false, ...gcsafe, raises: [Defect], raises: [Defect], tags: [RootEffect].}
- try acquiring a connection if all slots are already taken, raise TooManyConnectionsError exception Source Edit
proc triggerConnEvent(c: ConnManager; peerId: PeerId; event: ConnEvent): Future[ void] {....gcsafe, stackTrace: false, ...gcsafe, raises: [Defect], raises: [Defect], tags: [RootEffect].}
- Source Edit
proc triggerPeerEvents(c: ConnManager; peerId: PeerId; event: PeerEvent): Future[ void] {....gcsafe, stackTrace: false, ...gcsafe, raises: [Defect], raises: [Defect], tags: [RootEffect].}
- Source Edit