How to use peer method in wpt

Best JavaScript code snippet using wpt

high_availability.js

Source:high_availability.js Github

copy

Full Screen

...50 */51 // ------------------------------------------------------------------------52 ha.switch_peer = function (obj, options) {53 if (!options || !options.peer_urls || !options.peer_tls_opts) {54 logger.error('Missing options for switch_peer()');55 return { error: 'Missing options for switch_peer()' };56 }57 let next_peer_position = ha.using_peer_position + 1;58 if (next_peer_position >= options.peer_urls.length) { //wrap around59 next_peer_position = 0;60 }61 // --- Tried All Peers --- //62 if (next_peer_position === ha.success_peer_position) { //we've tried all peers, error out63 logger.error('Exhausted all peers. There are no more peers to try.');64 return { error: 'Exhausted all peers.' };65 } else {66 try { //remove current peer67 logger.warn('Switching peers!', ha.using_peer_position, next_peer_position);68 logger.debug('Removing peer from sdk client', options.peer_urls[ha.using_peer_position]);69 obj.channel.removePeer(new Peer(options.peer_urls[ha.using_peer_position], options.peer_tls_opts));70 } catch (e) {71 logger.error('Could not remove peer from sdk client', e);72 }73 // --- Use Next Peer --- //74 ha.using_peer_position = next_peer_position;75 const temp = {76 peer_url: options.peer_urls[ha.using_peer_position],77 peer_tls_opts: options.peer_tls_opts78 };79 ha.use_peer(obj, temp);80 return null;81 }82 };83 // ------------------------------------------------------------------------84 // Get the Event URl to use - returns null if there are NO urls85 /*86 options: {87 event_urls: ['array of peer grpc EVENT urls'], only used for invoke88 }89 */90 // ------------------------------------------------------------------------91 ha.get_event_url = function (options) {92 let ret = null;93 if (options && options.event_urls && options.event_urls[ha.using_peer_position]) {...

Full Screen

Full Screen

nrs.modals.peer.js

Source:nrs.modals.peer.js Github

copy

Full Screen

1/******************************************************************************2 * Copyright © 2013-2016 The Nxt Core Developers. *3 * Copyright © 2016-2017 Jelurida IP B.V. *4 * *5 * See the LICENSE.txt file at the top-level directory of this distribution *6 * for licensing information. *7 * *8 * Unless otherwise agreed in a custom licensing agreement with Jelurida B.V.,*9 * no part of the Nxt software, including this file, may be copied, modified, *10 * propagated, or distributed except according to the terms contained in the *11 * LICENSE.txt file. *12 * *13 * Removal or modification of this copyright notice is prohibited. *14 * *15 ******************************************************************************/16/**17 * @depends {nrs.js}18 * @depends {nrs.modals.js}19 */20var NRS = (function(NRS, $) {21 $("body").on("click", ".show_peer_modal_action", function(event) {22 event.preventDefault();23 if (NRS.fetchingModalData) {24 return;25 }26 NRS.fetchingModalData = true;27 var address = $(this).data("address");28 NRS.sendRequest("getPeer", { peer: address }, function(peer) {29 NRS.showPeerModal(peer);30 });31 });32 NRS.showPeerModal = function(peer) {33 try {34 var peerDetails = $.extend({}, peer);35 if (peerDetails.hallmark && NRS.isDecodePeerHallmark()) {36 var promise = new Promise(function(resolve, reject) {37 NRS.sendRequest("decodeHallmark", { hallmark: peerDetails.hallmark }, function(response) {38 if (response.errorCode) {39 reject(response);40 } else {41 resolve(response);42 }43 });44 });45 promise.then(function(response) {46 var hallmark = peerDetails.hallmark;47 delete peerDetails.hallmark;48 peerDetails.hallmark = hallmark;49 peerDetails.hallmarkAccount_formatted_html = NRS.getAccountLink(response, "account");50 peerDetails.hallmarkHost = response.host;51 peerDetails.hallmarkPort = response.port;52 peerDetails.hallmarkWeight = response.weight;53 peerDetails.hallmarkDate = response.date;54 peerDetails.hallmarkValid = response.valid;55 showPeerModalImpl(peerDetails);56 }).catch(function(response) {57 peerDetails.hallmarkError = response.errorDescription;58 showPeerModalImpl(peerDetails);59 })60 } else {61 showPeerModalImpl(peerDetails);62 }63 } finally {64 NRS.fetchingModalData = false;65 }66 };67 function showPeerModalImpl(peerDetails) {68 $("#peer_info").html(peerDetails.announcedAddress);69 peerDetails.state = NRS.getPeerState(peerDetails.state);70 if (peerDetails.lastUpdated) {71 peerDetails.lastUpdated = NRS.formatTimestamp(peerDetails.lastUpdated);72 }73 if (peerDetails.lastConnectAttempt) {74 peerDetails.lastConnectAttempt = NRS.formatTimestamp(peerDetails.lastConnectAttempt);75 }76 peerDetails.downloaded_formatted_html = NRS.formatVolume(peerDetails.downloadedVolume);77 delete peerDetails.downloadedVolume;78 peerDetails.uploaded_formatted_html = NRS.formatVolume(peerDetails.uploadedVolume);79 delete peerDetails.uploadedVolume;80 var detailsTable = $("#peer_details_table");81 detailsTable.find("tbody").empty().append(NRS.createInfoTable(peerDetails));82 detailsTable.show();83 $("#peer_modal").modal("show");84 }85 return NRS;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.peer(function(err, data) {4 if(err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var wpt = require('webpagetest');11var wpt = new WebPageTest('www.webpagetest.org');12 if(err) {13 console.log(err);14 } else {15 console.log(data);16 }17});18var wpt = require('webpagetest');19var wpt = new WebPageTest('www.webpagetest.org');20wpt.getLocations(function(err, data) {21 if(err) {22 console.log(err);23 } else {24 console.log(data);25 }26});27var wpt = require('webpagetest');28var wpt = new WebPageTest('www.webpagetest.org');29wpt.getTesters(function(err, data) {30 if(err) {31 console.log(err);32 } else {33 console.log(data);34 }35});36var wpt = require('webpagetest');37var wpt = new WebPageTest('www.webpagetest.org');

Full Screen

Using AI Code Generation

copy

Full Screen

1wpt.peer.onopen = function() {2 wpt.log("peer open");3 wpt.peer.send("hello");4}5wpt.peer.onmessage = function(e) {6 wpt.log("peer message: " + e.data);7}8wpt.peer.onclose = function() {9 wpt.log("peer close");10}11wpt.peer.onerror = function(e) {12 wpt.log("peer error: " + e);13}14wpt.peer.oniceconnectionstatechange = function(e) {15 wpt.log("peer ice connection state change: " + e);16}17wpt.peer.onicecandidate = function(e) {18 wpt.log("peer ice candidate: " + e);19}20wpt.peer.onicegatheringstatechange = function(e) {21 wpt.log("peer ice gathering state change: " + e);22}23wpt.peer.onsignalingstatechange = function(e) {24 wpt.log("peer signaling state change: " + e);25}26wpt.peer.ondatachannel = function(e) {27 wpt.log("peer data channel: " + e);28}29wpt.peer.onaddstream = function(e) {30 wpt.log("peer add stream: " + e);31}32wpt.peer.onremovestream = function(e) {33 wpt.log("peer remove

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var test = new wpt(options);5 if (err) return console.error(err);6 console.log(data);7});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful