@yoda/flora~ Agent

agent of flora connection

Constructor

new Agent(uri, options)

Parameters:
Name Type Description
uri string

uri of flora service

options object
Name Type Description
reconnInterval number

reconnect interval time when flora disconnected. default value 10000

bufsize number

flora msg buf size. default value 32768

beepInterval number

interval time of client send ping, only effective when connection is tcp protocol.

norespTimeout number

timeout of flora service no response, only effective when connection is tcp protocol.

Methods

(static) start()

start work

(static) close()

stop work

(static) unsubscribe(name)

unsubscribe flora msg

Parameters:
Name Type Description
name string

msg name for unsubscribe

(static) removeMethod(name)

remove remote method

Parameters:
Name Type Description
name string

method name

(static) subscribe(name, handler, options)

subscribe flora msg

Parameters:
Name Type Description
name string

msg name for subscribe

handler module:@yoda/flora~SubscribeMsgHandler

msg handler of received msg

options object
Name Type Description
format string

specify format of received message. format string values: 'array' | 'caps'

(static) declareMethod(name, handler, options)

declare remote method

Parameters:
Name Type Description
name string

method name

handler module:@yoda/flora~DeclareMethodHandler

handler of remote method call

options object
Name Type Description
format string

specify format of received method params. format string values: 'array' | 'caps'

(static) post(name, msg, type) → {number}

post msg

Parameters:
Name Type Description
name string

msg name

msg Array.<any> | module:@yoda/caps~Caps

msg content

type number

msg type: module:@yoda/flora~MSGTYPE_INSTANT module:@yoda/flora~MSGTYPE_PERSIST

Returns:
Type:
number

0 for success, otherwise error code

(static) call(name, msgopt, target, timeoutopt, optionsopt) → {Promise}

remote method call

Parameters:
Name Type Attributes Description
name string

msg name

msg Array.<any> | module:@yoda/caps~Caps <optional>

method params

target string

target client id of remote method

timeout number <optional>

remote call timeout

options object <optional>
Name Type Description
format string

specify format of method params. format string values: 'array' | 'caps'

Returns:
Type:
Promise

promise that resolves with {number} rescode, {module:@yoda/flora~Response}