Meerkat aims to be a typescript and webpack 5 friendly re-implementation of Bugout: A browser-to-browser networking built on WebTorrent
npm i @fabianbormann/meerkat
<script src="https://fabianbormann.github.io/meerkat/latest/meerkat.min.js"></script>
<script>
const meerkat = new Meerkat({ ... });
</script>
import Meerkat from '@fabianbormann/meerkat';
const meerkat = new Meerkat({ seed: localStorage['bugout-demo-server-seed'] });
localStorage['meerkat-server-seed'] = meerkat.seed;
let connected = false;
meerkat.on('connections', (clients) => {
if (clients === 0 && connected === false) {
connected = true;
console.log('[info]: server ready');
}
console.log(`[info]: ${clients} clients connected`);
});
meerkat.register('hello', (address, args, callback) => {
console.log(
`[info]: rpc call invoked by address ${address} into window.cardano`
);
callback('hello world');
});
console.log(`Share this address ${meerkat.address} with your clients`);
import Meerkat from '@fabianbormann/meerkat';
const meerkat = new Meerkat({ identifier: 'YOUR_SERVER_ADDRESS' });
meerkat.on('server', () => {
console.log('[info]: connected to server');
meerkat.rpc('YOUR_SERVER_ADDRESS', 'hello', {}, (response) =>
console.log(response)
);
});