Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Copyright 2015 Google Inc. All Rights Reserved.
// 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.
"use strict";
var jsonrpc = require('jayson');
var client = jsonrpc.client.https('https://issues.isocpp.org/jsonrpc.cgi');
let ConcurrencyLimit = require('./concurrencyLimit').ConcurrencyLimit;
let requestLimit = new ConcurrencyLimit(5);
function pRequest(method, argument) {
return requestLimit.whenReady(() =>
new Promise(function(resolve, reject) {
client.request(
method, [argument],
function(err, error, result) {
if (err) reject(err);
else resolve(result);
});
}));
};
const {app, BrowserWindow, ipcMain} = require('electron');
const path = require('path');
const jayson = require('jayson');
// tree-kill has better cross-platform handling of
// killing a process. child-process.kill was unreliable
const kill = require('tree-kill');
const child_process = require('child_process');
const assert = require('assert');
let client = jayson.client.http('http://localhost:5279/lbryapi');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win;
// Also keep the daemon subprocess alive
let daemonSubprocess;
// This is set to true right before we try to shut the daemon subprocess --
// if it dies when we didn't ask it to shut down, we want to alert the user.
let daemonSubprocessKillRequested = false;
// When a quit is attempted, we cancel the quit, do some preparations, then
// this is set to true and app.quit() is called again to quit for real.
let readyToQuit = false;
/*
* Replacement for Electron's shell.openItem. The Electron version doesn't
var jayson = require('jayson');
//backend_server/service.py
var client = jayson.client.http({
port: 4040,
hostname: 'localhost'
});
// Test RPC method
function add(a, b, callback) {
client.request('add', [a, b], function(err, error, response) {
if (err) throw err;
console.log(response);
callback(response);
});
}
// Get news summaries for a user
function getNewsSummariesForUser(user_id, page_num, callback) {
client.request('getNewsSummariesForUser', [user_id, page_num], function(err, error, response) {
var jayson = require('jayson');
// create a client
var client = jayson.client.http({
port: 4040,
hostname: 'localhost'
});
// Test method.
function add(a, b, callback) {
client.request('add', [a, b], function(err, response) {
if (err) throw err;
console.log(response.result);
callback(response.result);
});
}
// Get news summaries for a user.
function getNewsSummariesForUser(user_id, page_num, callback) {
import jayson from "jayson";
import {
SERVICE_USER_HOST,
SERVICE_USER_PORT,
SERVICE_MOVIE_HOST,
SERVICE_MOVIE_PORT
} from "./secrets";
// create a rpc client
export const userService = jayson.client.http({
hostname: SERVICE_USER_HOST,
port: SERVICE_USER_PORT
});
export const movieService = jayson.client.http({
hostname: SERVICE_MOVIE_HOST,
port: SERVICE_MOVIE_PORT
});
var jayson = require('jayson');
var log = require('loglevel');
// create a client
var client = jayson.client.http({
port: 3000
});
client.on('http request', (req) => {
log.debug("REQUEST:");
log.debug(req);
});
var obj = {'foo': 'bar'};
if (process.argv.length > 3) {
log.info("Loading object from command line");
obj = JSON.parse(process.argv[3]);
}
client.request(process.argv[2], [obj], function(err, response) {
if(err) throw err;
function peerCall(locator, method, values, validator, callback) {
let client
if (locator.includes('https')) {
client = jayson.client.https(locator)
} else {
client = jayson.client.http(locator)
}
client.request(method, values, function(err, error, quote) {
if (err) {
callback(`\n${chalk.yellow('Connection Error')}: ${locator} \n ${err}`)
} else {
if (error) {
callback(`\n${chalk.yellow('Maker Error')}: ${error.message}\n`)
} else if (!orders[validator](quote)) {
console.log(`\n${chalk.yellow('Got a Malformed Quote')}`)
console.log(quote)
} else {
callback(null, quote)
}
}
})
}
var makeClient = function (host) {
return jayson.client.http(host)
}
module.exports = (function() {
var URL = 'https://api.changelly.com';
var io = require('socket.io-client');
var jayson = require('jayson');
var crypto = require('crypto');
var client = jayson.client.https(URL);
function Changelly(apiKey, apiSecret) {
this._id = function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
};
this._sign = function(message) {
return crypto
.createHmac('sha512', apiSecret)
.update(JSON.stringify(message))
.digest('hex');
};