Example:
const network = require('ocore/network.js');const eventBus = require('ocore/event_bus.js');const ws = network.getInboundDeviceWebSocket(device_address);​// function parameters: websocket, subject, bodynetwork.sendJustsaying(ws, 'custom', 'some data');​eventBus.on('custom_justsaying', function(ws, content) {console.log(content);};
Following is a list of justsaying
type JSON messages that are sent over the network:
{type: 'justsaying',content: {subject: 'version',body: {protocol_version: protocol_version,alt: alt,library: name,library_version: version,program: program,program_version: program_version}}}
{type: 'justsaying',content: {subject: 'free_joints_end',body: null}}
{type: 'justsaying',content: {subject: 'private_payment',body: privateElement}}
{type: 'justsaying',content: {subject: 'my_url',body: my_url}}
{type: 'justsaying',content: {subject: 'want_echo',body: random_echo_string}}
{type: 'justsaying',content: {subject: 'your_echo',body: echo_string}}
{type: 'justsaying',content: {subject: 'hub/login',body: {challenge: challenge,pubkey: pubkey,signature: signature}}}
{type: 'justsaying',content: {subject: 'hub/refresh',body: null}}
{type: 'justsaying',content: {subject: 'hub/delete',body: message_hash}}
{type: 'justsaying',content: {subject: 'hub/challenge',body: challenge}}
{type: 'justsaying',content: {subject: 'hub/message',body: {message_hash: message_hash,message: message}}}
{type: 'justsaying',content: {subject: 'hub/message_box_status',body: 'has_more'}}
{type: 'justsaying',content: {subject: 'light/have_updates',body: null}}
{type: 'justsaying',content: {subject: 'light/sequence_became_bad',body: arrUniqueUnits}}
{type: 'justsaying',content: {subject: 'light/new_address_to_watch',body: address}}
{type: 'justsaying',content: {subject: 'bugreport',body: {message: message,exception: exception}}}
{type: 'justsaying',content: {subject: 'hub/push_project_number',body: {projectNumber: projectNumber}}}
{type: 'justsaying',content: {subject: 'new_version',body: {version: version}}}
{type: 'justsaying',content: {subject: 'exchange_rates',body: exchangeRates}}
{type: 'justsaying',content: {subject: 'upgrade_required',body: null}}
You can add your own communication protocol on top of the Obyte one. See event there.
{type: 'justsaying',content: {tag: tag,subject: 'custom',body: body}}