How to use the wampy function in wampy

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 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)
			});
		});
	}

wampy

Simple WAMP (WebSocket Application Messaging Protocol) Javascript implementation

MIT
Latest version published 3 months ago

Package Health Score

78 / 100
Full package analysis