Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
const wsUrl = `${useSsl ? 'wss' : 'ws'}://127.0.0.1:${targetServerPort}`;
const ws = new WebSocket.Client(wsUrl, [], {
proxy: {
origin: mainProxyUrl,
tls: useSsl ? { cert: sslCrt } : null,
}
});
ws.on('error', (err) => {
ws.close();
reject(err);
});
ws.on('open', () => {
ws.send('hello world');
});
ws.on('message', (event) => {
ws.close();
resolve(event.data);
return new Promise((resolve, reject) => {
const wsUrl = `${useSsl ? 'wss' : 'ws'}://127.0.0.1:${targetServerPort}`;
const ws = new WebSocket.Client(wsUrl, [], {
proxy: {
origin: mainProxyUrl,
tls: useSsl ? { cert: sslCrt } : null,
}
});
ws.on('error', (err) => {
ws.close();
reject(err);
});
ws.on('open', () => {
ws.send('hello world');
});
ws.on('message', (event) => {
ws.close();
resolve(event.data);
epoch: Math.round(new Date().getTime() / 1000.0)
};
var tripCoordinates = [
[51.681520, 39.183383],
[51.675932, 39.169736],
[51.670715, 39.161153],
[51.672419, 39.153171],
[51.675719, 39.143300],
[51.677901, 39.136691],
[51.680296, 39.129653],
[51.683448, 39.122151],
];
var WebSocket = require('faye-websocket'),
client = new WebSocket.Client('ws://localhost:9000/');
client.on('open', function(event) {
console.log('WebSocket client connected');
client.sendWithLog = function(message) {
console.log('Sending ' + message.messageType);
console.log(message);
this.send(JSON.stringify(message));
};
client.sendWithLog(login1);
});
client.on('close', function(event) {
console.log('Connection Closed', event.code, event.reason);
makeSocket: function(url, title, onMessage, send) {
if (typeof url != "string" || typeof title != "string") {
return false;
}
if (typeof Sockets[title] == "undefined" || !Sockets[title]) {
Sockets[title] = {};
}
Sockets[title] = new WebSocket.Client(url);
try {
Sockets[title].on('open', function(event) {
console.log(title + ' open');
if (typeof Exchanges[title] == "undefined" && title != "gemini2") {
Exchanges[title] = {};
}
})
} catch (error) {
console.log(error);
return false;
}
try {
Sockets[title].on('close', function(event) {
console.log(title + ' close');
region: "Коминтерновский район",
city: "Воронеж",
longitude: 39.122151,
latitude: 51.683448
}
};
cancelPickup = {
messageType: "PickupCanceledClient",
longitude: 39.122151,
latitude: 51.683448,
app: 'client',
};
var WebSocket = require('faye-websocket'),
client = new WebSocket.Client('ws://localhost:9000/');
var timeId;
client.on('open', function(event) {
console.log('WebSocket client connected');
client.sendWithLog = function(message) {
console.log('Sending ' + message.messageType);
console.log(message);
this.send(JSON.stringify(message));
};
client.sendWithLog(login);
if (timeId) clearInterval(timerId);
function connect(prefixes) {
if (prefixes.length === 0) {
writelog({
app: 'git-azure',
type: 'stderr',
data: 'Unable to establish a WebSocket connection to either wss://' + config.sanitizedEndpoint
+ ' or ws://' + config.sanitizedEndpoint + '.'
});
process.exit(1);
}
var prefix = prefixes.shift();
var connected;
var ws = new WebSocket(prefix + config.endpoint);
ws.onopen = function () {
writelog({
app: 'git-azure',
type: 'system',
data: 'Connected to ' + prefix + config.sanitizedEndpoint + '. Waiting for logs...'
});
connected = true;
}
ws.onclose = function () {
if (connected) {
writelog({
app: 'git-azure',
type: 'stderr',
setTimeout(function() {
client = new WebSocket.Client('ws://localhost:9000/');
}, 500);
});
if (toSocket) {
jx_obj.Socket.send(jx_obj.SFirst[o]);
} else {
jx_obj.Send(jx_obj.SFirst[o], false, true);
}
}
jx_obj.SFirst = [];
}
};
if (jx_obj.Socket == null) {
var url = jx_obj.IsSecure ? "wss://" : "ws://";
url += jx_obj.SocketURL + ":" + jx_obj.SocketPort + jx_obj.ListenUrl + "c=" + jx_obj.clid + "&sid=" + jx_obj.SecuredKey;
jx_obj.Socket = new WebSocket.Client(url);
jx_obj.Socket.on('open', function () {
jx_obj.SocketOpen = true;
sendFirsts(true);
});
jx_obj.Socket.on('message', function (event) {
var d = event.data.toString();
jx_obj.ParseMessages(d);
});
jx_obj.Socket.on('error', function (event) {
jx_obj.Socket = null;
jx_obj.SocketDisabled = true;
jx_obj.Act("15", false);
errorMessage("Socket error. Falling back to reverse ajax: " + event.message.replace(event.target.url, ""));
_createWebsocket: function(url) {
return new WebSocket.Client(url, [], { extensions: this._dispatcher.wsExtensions });
},
});
DDPClient.prototype._makeWebSocketConnection = function(url) {
var self = this;
self.socket = new WebSocket.Client(url, null, self.tlsOpts);
self._prepareHandlers();
};