Members
allowMultiplySocketsOnBus :boolean
Allows multiple connections from one bus address
if TRUE we don't check
Type:
- boolean
block :Block
Type:
- Block
blockHeight :number
Blockchain height
Type:
- number
maxConnections :number
Max connections
Type:
- number
messagesHandlers :Array
Messages handlers
Type:
- Array
nodeList
Nodes list
recieverAddress :string
Current reciever address. Override allowed
Type:
- string
routes :Object
Known routes
Type:
- Object
secretKeys :Object
Known secret keys
consist of secret keys of different busAddresses of peers
Type:
- Object
sockets :Array
All sockets list
Type:
- Array
Methods
autoconnect(force)
Reconnecting peers if fully disconnected
Parameters:
Name | Type | Description |
---|---|---|
force |
boolean | reconnection |
broadcast(message) → {boolean}
Broadcast message to peers
Parameters:
Name | Type | Description |
---|---|---|
message |
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 |
checkForLoad()
Watchdog timer action
- Source:
connectPeer(peer)
Inits peer connection
Parameters:
Name | Type | Description |
---|---|---|
peer |
String |
getid() → {string}
Generate uniq id string
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 |
ondata(data)
On data recived callback
Parameters:
Name | Type | Description |
---|---|---|
data |
String |
onmessage(message)
If message recived
Parameters:
Name | Type | Description |
---|---|---|
message |
object |
onready()
On blockchain connection ready
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 |
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) |
requestApp(uri, data, callback, timeout)
Creates request to app like $.ajax request
Parameters:
Name | Type | Description |
---|---|---|
uri |
string | |
data |
object | |
callback |
function | |
timeout |
int |
start()
Starts connection to blockchain