How to use wampy - 7 common examples

To help you get started, we’ve selected a few wampy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / wampy / wampy-tests.ts View on Github external
/// 
/// 

import Wampy from 'wampy';

var ws = new Wampy('http://wamp.router.url', {realm: 'WAMPRealm'});

ws.options();

ws.options({
    reconnectInterval: 1000,
    maxRetries: 999,
    onConnect: function () { console.log('Yahoo! We are online!'); },
    onClose: function () { console.log('See you next time!'); },
    onError: function () { console.log('Breakdown happened'); },
    onReconnect: function () { console.log('Reconnecting...'); },
    onReconnectSuccess: function () { console.log('Successfully reconnected!'); }
});

ws.connect();
ws.connect('/my-socket-path');
ws.connect('wss://socket.server.com:5000/ws');
github Orckestra / C1-CMS-Foundation / Website / Composite / console / mocks / mockServer.js View on Github external
url.protocol = 'ws:';

function RPCWrapper (handler) {
	return (args) => [{}, handler(...args)];
}

// XXX: This is nasty. Happily it's also temporary.
let unblock;
const wait = new Promise(resolve => {
	unblock = () => resolve(true);
});
export function waitFor() {
	return wait;
}

const client = new Wampy(url.href, {
	realm: 'realm1',
	onConnect: () => {
		Promise.all([
			registerMock('alive', () => true),
			// Register other mock rpcs.
			registerMock('struct.page', pageFetcher),
			registerMock('data.values.load', valueFetcher),
			registerMock('data.values.save', valuePutter),
			registerMock('provider.components.list', getFunctions),
			registerMock('provider.components.pick', pickFunction),
			registerMock('struct.dialog.cancel', dialogName =>
				console.log('Canceling and closing', dialogName) // eslint-disable-line no-console
			),
		]).then(unblock);
	}
});
github golemfactory / golem-electron / src / sagas / index.js View on Github external
function connect() {
            let connection = new Wampy(config.WS_URL,
                {
                    realm: config.REALM,
                    autoReconnect: true,
                    transportEncoding: 'msgpack',
                    msgpackCoder: new MsgpackSerializer(),
                    onConnect: () => {
                        console.log('WS: connected');

                        resolve({
                            connection
                        });
                    },
                    onClose: () => {
                        console.log('WS: connection closed');
                    },
                    onError: (err, details) => {
github 9inevolt / betterdgg / chrome / lib / service.js View on Github external
chrome.runtime.onConnect.addListener(function(port) {
    var wamp = new Wampy(address, {
        realm: 'bdgg',
        onConnect: function() {
            //console.log('wamp connected');
        },
        onError: function(e) { console.error('wamp error: ' + e); }
    });

    wamp.subscribe('bdgg.flair.refresh', {
        onSuccess: function() {
            //console.log('successfully subscribed');
        },
        onError: function(err) { console.error('subscription error: ' + err); },
        onEvent: function(data) {
            //console.log('refresh: ' + data);
            postUsers(data.users);
        }
github Orckestra / C1-CMS-Foundation / Website / Composite / console / access / wampClient.js View on Github external
return new Promise((resolve, reject) => {
			let url = new URL(getBaseUrl() + '/Composite/api/Router', location.href);
			url.protocol = url.protocol.replace('http', 'ws');
			const client = new Wampy(url.href, {
				realm,
				onConnect: () => {
					currentClients[realm] = client;
					resolve(client);
				},
				onError: err => reject(err)
			});
		});
	}
github gammazero / nexus / examples / interop / wampy-nodejs / client.ts View on Github external
this.connectP = new Promise((resolve, reject) => {
                this.log("connecting...");
                let w3cws = require("websocket").w3cwebsocket;
                this.ws = new Wampy("ws://127.0.0.1:"+this.options.port+"/", {
                    ws: w3cws,
                    realm: this.options.realm||"nexus.example",
                    onConnect: () => {
                        this.log("connection - connect success");
                        resolve(this.ws);
                    },
                    onError: err => {
                        this.log("connection - error!");
                        reject(err);
                    },
                    onClose: () => {
                        this.log("connection - closed");
                    },
                    debug: false,
                    autoReconnect: true
                });
github nearprotocol / near-wallet / src / utils / explorer-api.js View on Github external
import { Wampy } from 'wampy'

const WAMP_NEAR_EXPLORER_URL = process.env.WAMP_NEAR_EXPLORER_URL || 'wss://near-explorer-wamp.onrender.com/ws'

const wamp = new Wampy(WAMP_NEAR_EXPLORER_URL, { realm: 'near-explorer' })

export async function getTransactions(accountId = '') {
    if (!this.accountId) return null
    if (!accountId) accountId = this.accountId

    const tx = await new Promise((resolve, reject) => wamp.call(
        'com.nearprotocol.testnet.explorer.select',
        [
            `
               SELECT 
                  transactions.hash,
                  transactions.signer_id, 
                  transactions.receiver_id, 
                  transactions.actions, 
                  transactions.block_hash, 
                  blocks.timestamp as blockTimestamp

wampy

Simple WAMP (WebSocket Application Messaging Protocol) Javascript implementation

MIT
Latest version published 3 months ago

Package Health Score

81 / 100
Full package analysis