Metacom protocol specification: https://github.com/metarhia/Contracts/blob/master/doc/Metacom.md
// Load at frontend
import { Metacom } from './metacom.js';
// Load at backend
const { Metacom } = require('metacom');
// Open connection (both platforms) and make calls
const metacom = Metacom.create('https://domainname.com:8000');
(async () => {
const { api } = metacom;
try {
await metacom.load('auth'); // Load `auth` interface
await api.auth.status(); // Check session status
} catch (err) {
await api.auth.signIn({ login: 'marcus', password: 'marcus' });
}
await metacom.load('example'); // Load `example` interface
const result = api.example.methodName({ arg1, arg2 });
})();