wallet/device.js
function sendPreparedMessageToHub(ws, recipient_device_pubkey, message_hash, json, callbacks){
	if (!callbacks)
		callbacks = {ifOk: function(){}, ifError: function(){}};
	if (typeof ws === "string"){
		var hub_host = ws;
		network.findOutboundPeerOrConnect(conf.WS_PROTOCOL+hub_host, function onLocatedHubForSend(err, ws){
			if (err)
				return callbacks.ifError(err);
			sendPreparedMessageToConnectedHub(ws, recipient_device_pubkey, message_hash, json, callbacks);
		});
	}
	else
		sendPreparedMessageToConnectedHub(ws, recipient_device_pubkey, message_hash, json, callbacks);
}
function sendPreparedMessageToHub(ws, recipient_device_pubkey, message_hash, json, callbacks){
	if (!callbacks)
		callbacks = {ifOk: function(){}, ifError: function(){}};
	if (typeof ws === "string"){
		var hub_host = ws;
		network.findOutboundPeerOrConnect(conf.WS_PROTOCOL+hub_host, function onLocatedHubForSend(err, ws){
			if (err)
				return callbacks.ifError(err);
			sendPreparedMessageToConnectedHub(ws, recipient_device_pubkey, message_hash, json, callbacks);
		});
	}
	else
		sendPreparedMessageToConnectedHub(ws, recipient_device_pubkey, message_hash, json, callbacks);
}
function sendPreparedMessageToHub ( ws , recipient_device_pubkey , message_hash , json , callbacks ) { if ( ! callbacks ) callbacks = { ifOk : function ( ) { } , ifError : function ( ) { } } ; if ( typeof ws === "string" ) { var hub_host = ws ; network . findOutboundPeerOrConnect ( conf . WS_PROTOCOL + hub_host , function onLocatedHubForSend ( err , ws ) { if ( err ) return callbacks . ifError ( err ) ; sendPreparedMessageToConnectedHub ( ws , recipient_device_pubkey , message_hash , json , callbacks ) ; } ) ; } else sendPreparedMessageToConnectedHub ( ws , recipient_device_pubkey , message_hash , json , callbacks ) ; }
first param is either WebSocket or hostname of the hub
first param is either WebSocket or hostname of the hub