Global

Members

allowMultiplySocketsOnBus :boolean

Allows multiple connections from one bus address if TRUE we don't check
Type:
  • boolean
Source:

block :Block

Type:
  • Block
Source:

blockHeight :number

Blockchain height
Type:
  • number
Source:

maxConnections :number

Max connections
Type:
  • number
Source:

messagesHandlers :Array

Messages handlers
Type:
  • Array
Source:

nodeList

Nodes list
Source:

recieverAddress :string

Current reciever address. Override allowed
Type:
  • string
Source:

routes :Object

Known routes
Type:
  • Object
Source:

secretKeys :Object

Known secret keys consist of secret keys of different busAddresses of peers
Type:
  • Object
Source:

sockets :Array

All sockets list
Type:
  • Array
Source:

Methods

autoconnect(force)

Reconnecting peers if fully disconnected
Parameters:
Name Type Description
force boolean reconnection
Source:

broadcast(message) → {boolean}

Broadcast message to peers
Parameters:
Name Type Description
message
Source:
Returns:
sending status
Type
boolean

broadcastMessage(messageData, id, reciver, recipient)

Broadcast global message
Parameters:
Name Type Description
messageData object Message data
id string Message ID
reciver string Receiver address
recipient string Recipient address
Source:

checkForLoad()

Watchdog timer action
Source:

connectPeer(peer)

Inits peer connection
Parameters:
Name Type Description
peer String
Source:

getid() → {string}

Generate uniq id string
Source:
Returns:
Type
string

imgAutoLoad()

Load all Candy images
Source:

loadResource(blockId, callback)

Load resource from blockchain
Parameters:
Name Type Description
blockId Number Block index
callback function Callback function
Source:

ondata(data)

On data recived callback
Parameters:
Name Type Description
data String
Source:

onmessage(message)

If message recived
Parameters:
Name Type Description
message object
Source:

onready()

On blockchain connection ready
Source:

onready()

Starts watchdog timer on ready
Source:

registerMessageHandler(id, handler)

Add message handler
Parameters:
Name Type Description
id string Message ID
handler function Handler function
Source:

request(uri, data, callback, timeout)

Universal request function. For request data from vitamin chain use "block" as host name and bock id as path. Ex: candy://block/14 For application request use candy://hostname/filepath?get=query Data and timeout ignored in block request
Parameters:
Name Type Description
uri string Uri string
data object Data object
callback function Callback function
timeout int Request timeout (deprecated)
Source:

requestApp(uri, data, callback, timeout)

Creates request to app like $.ajax request
Parameters:
Name Type Description
uri string
data object
callback function
timeout int
Deprecated:
  • Yes
Source:

start()

Starts connection to blockchain
Source: