Documentation
    Preparing search index...

    Interface IPeerkitNode

    Interface that the peerkit node exposes to modules

    Modules depend on this interface only, so that they can be distributed without a dependency on the peerkit package.

    interface IPeerkitNode {
        ownAgentId: string;
        createStream(agentId: string, protocol: string): Promise<IStream>;
        getConnectedAgents(): string[];
        register(module: INodeModule): void;
        registerStreamHandler(
            protocol: string,
            handler: (fromAgent: string, stream: IStream) => void,
        ): void;
    }

    Implemented by

    Index

    Properties

    ownAgentId: string

    The local node's stable agent identity.

    Methods

    • Open an outgoing stream to a connected agent on the given protocol.

      Throws if the agent is not connected.

      Parameters

      • agentId: string
      • protocol: string

      Returns Promise<IStream>

    • Return the AgentIds of all currently connected peers.

      Returns string[]

    • Attach a module to this node.

      Calls module.init(this) to wire it up, then module.start() if defined. Multiple modules can be registered.

      Parameters

      Returns void

    • Register a handler for incoming streams on the given protocol.

      Called once per incoming stream, after the access check has passed.

      Parameters

      • protocol: string
      • handler: (fromAgent: string, stream: IStream) => void

      Returns void