Skip to content

Client

@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/rpc-client

RPC client helpers

Example

import RpcClient from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/rpc-client'

Example

import RpcClients from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/rpc-client'

exports.RpcClient(param) ⇒ Object

Contain functionality for using RPC conection

Kind: Exported function
rtype: Stamp

Param Type Description
param Object Init params object
param.id String Client id
param.name String Client name
param.connection Object Connection object
param.handlers Array.<function()> Arrays with two function for handling messages ([ onMessage: Function, onDisconnect: Function])

exports.RpcClient.addClient(id, connectionData) ⇒ void

Add new client

Kind: instance method of exports.RpcClient
rtype: (id: (String|Number), connectionInfo: Object) => void

Param Type Description
id String | Number Client ID
connectionData Object Object containing connectionInfo and connection objects

exports.RpcClient.getClient(id) ⇒ Object

Get clien by id

Kind: instance method of exports.RpcClient
Returns: Object - RpcClient
rtype: (id: (String|Number)) => Object

Param Type Description
id String | Number Client ID

exports.RpcClient.updateClientInfo(id, info) ⇒ void

Update client info by id

Kind: instance method of exports.RpcClient
rtype: (id: (String|Number), info: Object) => void

Param Type Description
id String | Number Client ID
info Object Info to update (will be merged with current info object)

exports.RpcClient.sentNotificationByCondition(msg, condition) ⇒ void

Send notification to all client passing condition

Kind: instance method of exports.RpcClient
rtype: (msg: Object, condition: Function) => void

Param Type Description
msg Object Msg object
condition function Condition function of (client: RpcClient) => Boolean

exports.RpcClient.isConnected() ⇒ Boolean

Check if is connected

Kind: instance method of exports.RpcClient
Returns: Boolean - is connected
rtype: () => Boolean

exports.RpcClient.getCurrentAccount(options) ⇒ String

Get selected account

Kind: instance method of exports.RpcClient
rtype: ({ onAccount } = {}) => String

Param Type Description
options Object Options

exports.RpcClient.disconnect() ⇒ void

Disconnect

Kind: instance method of exports.RpcClient
rtype: () => void

exports.RpcClient.updateSubscription(type, value) ⇒ Array.<String>

Update subsription

Kind: instance method of exports.RpcClient
rtype: (type: String, value: String) => void

Param Type Description
type String Subscription type
value String Subscription value

exports.RpcClient.addAction(action, resolvers) ⇒ Object

Add new action to actions

Kind: instance method of exports.RpcClient
rtype: (action: Object, [r: Function, j: Function]) => Object

Param Type Description
action Object Action object
resolvers Array.<function()> Array with two function [resolve, reject] action

exports.RpcClient.addCallback(msgId) ⇒ Promise

Add new callback for request

Kind: instance method of exports.RpcClient
Returns: Promise - Promise which will be resolved after receiving response message
rtype: (msgId: (String|Number)) => Object

Param Type Description
msgId String | Number Request message id

exports.RpcClient.processResponse(msg, [transformResult]) ⇒ void

Process response message

Kind: instance method of exports.RpcClient
rtype: (msg: Object, transformResult: Function) => void

Param Type Description
msg Object Message object
[transformResult] function Optional parser function for message

exports.RpcClient.resolveCallback(msgId, args) ⇒ void

Resolve callback function Trigger Promise resolution from addCallBack function

Kind: instance method of exports.RpcClient
rtype: (msgId: Number, args: Array) => void

Param Type Description
msgId Number Message Id
args Array Arguments array

exports.RpcClient.rejectCallback(msgId, args) ⇒ void

Reject callback function Trigger Promise rejection from addCallBack function

Kind: instance method of exports.RpcClient
rtype: (msgId: Number, args: Array) => void

Param Type Description
msgId Number Message Id
args Array Arguments array