@sallar-network/client
v1.0.2
Published
Client-side library to communicate your program running on the sallar network with your backend server
Readme
@sallar-network/client
Description
Client-side library to communicate your program running on the sallar network with your backend server.
Installation
$ npm i @sallar-network/clientor via cdn:
<script src="https://cdn.jsdelivr.net/npm/@sallar-network/[email protected]/dist/index.global.js"></script>Docs
$ npm run generate-docsBuild
You can build and test the library on your own:
$ npm run buildAnd add to your project via npm:
$ npm link
$ npm link @sallar-network/serveror module js:
import { InstanceManager } from './dist/index.mjs';or window global object:
<script src="/dist/index.global.js"></script>Example
index.html
<!-- You have to include socket.io first -->
<script src="https://cdn.socket.io/4.7.2/socket.io.min.js"></script>
<!-- The library -->
<script src="https://cdn.jsdelivr.net/npm/@sallar-network/[email protected]/dist/index.global.js"></script>
<!-- Your program -->
<script type="module" src="/program.js"></script>program.js
const program = new SallarNetworkClient.InstanceManager(io);
program.on('say-hello', (_, manager) => {
manager.emit('hello');
});