@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

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) 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) 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) get(name, msgopt, options) → {Promise}

post msg and get response

Parameters:
Name Type Attributes Description
name string

msg name

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

msg content

options object
Name Type Description
format string

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

Returns:
Type:
Promise

promise that resolves with an array of {module:@yoda/flora~Response}