πŸ”§ Constants

βš™ client

ConstantType
clientClientAPI

🏭 ClientAPI

Constructors

public: Creates a new ClientAPI instance

Parameters:

Methods

βš™ getSessionManager

MethodType
getSessionManager() => SessionManager

βš™ onP2PRequest

Registers a handler function for incoming P2P RPC requests from peers

MethodType
onP2PRequest(handler: (this: void, src: string, action: string, params: Record<string, unknown>) => unknown) => void

Parameters:

βš™ onP2PMessage

Registers a handler function for incoming direct P2P data messages

MethodType
onP2PMessage(handler: (this: void, src: string, payload: DirectMessagePayload) => void) => void

Parameters:

βš™ establishP2PSession

Requests a P2P ticket from the central KDC server and sends the handshake ticket to the target peer.

MethodType
establishP2PSession(peerId: string) => Promise<string>

βš™ listen

Continuously listens for incoming network packets and dispatches responses / P2P handlers. Consider running in parallel using parallel.waitForAny / waitForAll.

MethodType
listen() => void

βš™ request

Issues an RPC request to the Server and returns a Promise for the response.

MethodType
request(action: string, params?: Record<string, unknown>) => Promise<unknown>

βš™ requestP2P

Issues an RPC request directly to a Peer computer using an encrypted P2P session key. Automatically requests a session key from the server if one is not yet established.

MethodType
requestP2P(peerId: string, action: string, params?: Record<string, unknown>) => Promise<unknown>

βš™ sendP2P

Sends a direct encrypted message (chat/data) to a Peer computer using the shared P2P session key. Automatically requests a session key from the server if one is not yet established.

MethodType
sendP2P(peerId: string, content: any) => Promise<void>

βš™ listCurrency

Retrieves the balance and transaction list for this client from the server.

MethodType
listCurrency() => Promise<CurrencyListResponse>

βš™ getBalance

Retrieves the current currency balance for this client.

MethodType
getBalance() => Promise<number>

βš™ transfer

Sends currency from this computer to a recipient computer.

MethodType
transfer(toClientId: string, amount: number, note?: string) => Promise<CurrencyActionResult>

βš™ createTransaction

Creates a currency transaction (direct transfer or payment request from another computer).

MethodType
createTransaction(toClientId: string, amount: number, note?: string, fromClientId?: string or undefined) => Promise<CurrencyActionResult>

βš™ authorizeTransaction

Authorizes a pending currency transaction where this client is the sender/payer.

MethodType
authorizeTransaction(transactionId: string) => Promise<CurrencyActionResult>

βš™ processTransaction

Processes an authorized currency transaction where this client is the recipient.

MethodType
processTransaction(transactionId: string) => Promise<CurrencyActionResult>