Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function AddressService($http) {
var self = this; // 'this' is not available in the success function of $http.get
this.user = null;
this.closeEvent = null;
this.outstanding_settles = {};
this.error_queue = [];
this.admin_disabled = true;
this.address_index = {};
this.connection_index = {};
Object.defineProperty(this, 'addresses', { get: function () { return get_items_from_index(self.address_index); } });
Object.defineProperty(this, 'connections', { get: function () { return get_items_from_index(self.connection_index); } });
this.address_types = [];
this.address_space_type = '';
this._additional_listeners = [];
var ws = rhea.websocket_connect(WebSocket);
var connectionDetails = ws("wss://" + location.hostname + ":" + location.port + "/websocket", ["binary", "AMQPWSB10"]);
this.connection = rhea.create_connection({"connection_details": connectionDetails, "reconnect":15000, rejectUnauthorized:true});
this.connection.on('message', this.on_message.bind(this));
this.connection.on('connection_open', function (context) {
self.update_periodic_deltas_interval = setInterval(self.update_periodic_deltas.bind(self), 5000);
self.update_depth_series_interval = setInterval(self.update_depth_series.bind(self), 30000);
if (self.callback) {
self.callback("peer_connected");
}
});
this.connection.on('disconnected', function (context) {
self.closeEvent = context.error;
if (self.update_periodic_deltas_interval) {
clearInterval(self.update_periodic_deltas_interval);
self.update_periodic_deltas_interval = null;
}
function (resolve, reject) {
var timeout = options.timeout || 10000;
var reconnect = options.reconnect || false; // in case options.reconnect is undefined
var baseAddress = options.address + ":" + options.port;
if (options.linkRouteAddress) {
baseAddress += "/" + options.linkRouteAddress;
}
var wsprotocol = window.location.protocol === "https:" ? "wss" : "ws";
if (this.connection) {
delete this.connection;
this.connection = null;
}
var ws = rhea.websocket_connect(WebSocket);
var c = {
connection_details: new ws(wsprotocol + "://" + baseAddress, [
"binary"
]),
reconnect: reconnect,
properties: options.properties || {
console_identifier: "Dispatch console"
}
};
if (options.hostname) c.hostname = options.hostname;
if (options.username && options.username !== "") {
c.username = options.username;
}
if (options.password && options.password !== "") {
c.password = options.password;
}
function AddressService($http) {
var self = this; // 'this' is not available in the success funtion of $http.get
this.addresses = [];
this.address_types = [];
this.connections = [];
this.users = [];
var ws = rhea.websocket_connect(WebSocket);
this.connection = rhea.connect({"connection_details":ws("ws://" + location.hostname + ":" + location.port + "/websocket", ["binary", "AMQPWSB10"]), "reconnect":true});
this.connection.on('message', this.on_message.bind(this));
this.sender = this.connection.open_sender();
this.connection.open_receiver();
setInterval(this.update_periodic_deltas.bind(this), 30000);
setInterval(this.update_depth_series.bind(this), 30000);
this.tooltip = {}
$http.get('tooltips.json')
.then(function (d) {
self.tooltip = d.data;
})
}
return new Promise((function (resolve, reject) {
var timeout = options.timeout || 10000;
var reconnect = options.reconnect || false; // in case options.reconnect is undefined
var baseAddress = options.address + ':' + options.port;
if (options.linkRouteAddress) {
baseAddress += ('/' + options.linkRouteAddress);
}
var wsprotocol = location.protocol === 'https:' ? 'wss' : 'ws';
if (this.connection) {
delete this.connection;
this.connection = null;
}
var ws = rhea.websocket_connect(WebSocket);
var c = {
connection_details: new ws(wsprotocol + '://' + baseAddress, ['binary']),
reconnect: reconnect,
properties: options.properties || { console_identifier: 'Dispatch console' }
};
if (options.hostname)
c.hostname = options.hostname;
if (options.username && options.username !== '') {
c.username = options.username;
}
if (options.password && options.password !== '') {
c.password = options.password;
}
// set a timeout
var disconnected = (function () {
clearTimeout(timer);
function append(txt) {
var node = document.createTextNode(txt);
var div = document.createElement("div");
div.appendChild(node);
document.body.appendChild(div);
}
client.on("message", function (context) {
append('received: ' + context.message.body);
if (current++ < requests) {
next_request();
} else {
context.connection.close();
}
});
var ws = client.websocket_connect(WebSocket);
var connection = client.connect({
"connection_details": ws(server, protocols), transport: 'tls',
username: username, password: password, "reconnect": false
});
connection.open_receiver(address);
sender = connection.open_sender(address);
}
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var client = require('rhea');
var WebSocket = require('ws');
var ws = client.websocket_connect(WebSocket);
var args = require('../options.js').options({
'm': { alias: 'messages', default: 100, describe: 'number of messages to send'},
'u': { alias: 'url', default: 'ws://localhost:5673', describe: 'url to connect to'}
}).help('help').argv;
var requests = args.messages;
var current = 1;
var sender;
function next_request() {
var msg = 'request-' + current;
sender.send({body:msg})
console.log('sent ' + msg);
}
function AddressService() {
this.addresses = [];
this.flavors = [];
this.connections = [];
this.users = [];
var ws = rhea.websocket_connect(WebSocket);
this.connection = rhea.connect({"connection_details":ws("ws://" + location.hostname + ":" + location.port + "/websocket", ["binary", "AMQPWSB10"]), "reconnect":true});
this.connection.on('message', this.on_message.bind(this));
this.sender = this.connection.open_sender();
this.connection.open_receiver();
setInterval(this.update_periodic_deltas.bind(this), 30000);
setInterval(this.update_depth_series.bind(this), 30000);
}
var node = document.createTextNode(txt);
var div = document.createElement("div");
div.appendChild(node);
document.body.insertBefore(div, input);
input.scrollIntoView();
}
input.onchange = function() {
sender.send({"body":input.value});
input.value = "";
};
var client = require("rhea");
client.on("message", function (context) {
append(context.message.body);
});
var ws = client.websocket_connect(WebSocket);
var connection = client.connect({"connection_details":ws(server, ["binary", "AMQPWSB10", "amqp"]), "reconnect":false});
connection.open_receiver("examples");
var sender = connection.open_sender("examples");