π§ Constants
β client
| Constant | Type |
|---|---|
client | ClientAPI |
π ClientAPI
Constructors
public: Creates a new ClientAPI instance
Parameters:
clientId: The client IDmasterKey: The master keyserverId: The server ID (default: βSERVERβ)
Methods
- getSessionManager
- onP2PRequest
- onP2PMessage
- establishP2PSession
- listen
- request
- requestP2P
- sendP2P
- listCurrency
- getBalance
- transfer
- createTransaction
- authorizeTransaction
- processTransaction
β getSessionManager
| Method | Type |
|---|---|
getSessionManager | () => SessionManager |
β onP2PRequest
Registers a handler function for incoming P2P RPC requests from peers
| Method | Type |
|---|---|
onP2PRequest | (handler: (this: void, src: string, action: string, params: Record<string, unknown>) => unknown) => void |
Parameters:
handler: The handler function to register
β onP2PMessage
Registers a handler function for incoming direct P2P data messages
| Method | Type |
|---|---|
onP2PMessage | (handler: (this: void, src: string, payload: DirectMessagePayload) => void) => void |
Parameters:
handler: The handler function to register
β establishP2PSession
Requests a P2P ticket from the central KDC server and sends the handshake ticket to the target peer.
| Method | Type |
|---|---|
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.
| Method | Type |
|---|---|
listen | () => void |
β request
Issues an RPC request to the Server and returns a Promise for the response.
| Method | Type |
|---|---|
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.
| Method | Type |
|---|---|
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.
| Method | Type |
|---|---|
sendP2P | (peerId: string, content: any) => Promise<void> |
β listCurrency
Retrieves the balance and transaction list for this client from the server.
| Method | Type |
|---|---|
listCurrency | () => Promise<CurrencyListResponse> |
β getBalance
Retrieves the current currency balance for this client.
| Method | Type |
|---|---|
getBalance | () => Promise<number> |
β transfer
Sends currency from this computer to a recipient computer.
| Method | Type |
|---|---|
transfer | (toClientId: string, amount: number, note?: string) => Promise<CurrencyActionResult> |
β createTransaction
Creates a currency transaction (direct transfer or payment request from another computer).
| Method | Type |
|---|---|
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.
| Method | Type |
|---|---|
authorizeTransaction | (transactionId: string) => Promise<CurrencyActionResult> |
β processTransaction
Processes an authorized currency transaction where this client is the recipient.
| Method | Type |
|---|---|
processTransaction | (transactionId: string) => Promise<CurrencyActionResult> |