mikudos-socketio-client
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

Mikudos Client

Mikudos

MIKUDOS SOCKETIO CLIENT

mikudos-socketio-client for connection and call methods and sync events on mikudos-socketio-app server, which is provided only for socket.io connection.

node version version npm version license downloads collaborators typescript

Usage

Import the mikudos-socketio-client module:

import { MikudosSocketIoClient } from 'mikudos-socketio-client';
var { MikudosSocketIoClient } = require('mikudos-socketio-client');

MikudosSocketIoClient

General client for MikudosSocketIoClient:

const client = new MikudosSocketIoClient(
    {
        // same uri and option string will pass to socket.io generator as io(uri, option);
        uri: 'ws://localhost:3030',
        option: {}
    },
    {
        rpcEventName: 'rpc-call' // the path for remote rpc-call
    },
    token => {
        saveToken(token);
    },
    () => window.localstorage.jwt
);

Authentication

Authentication the client connection.

client
    .authentication({
        strategy: 'local',
        email: 'email',
        password: 'password'
    })
    .then(res => {
        console.log('TCL: res', res);
    })
    .catch(err => {
        console.log('TCL: err', err);
    });

client
    .authentication({
        strategy: 'jwt',
        accessToken: 'your_token' || 'Bearer your_token'
    })
    .then(res => {
        console.log('TCL: res', res);
    })
    .catch(err => {
        console.log('TCL: err', err);
    });

Call JSON-rpc server method

client
    .rpcCall({
        method: 'rpc_1.add',
        params: [1, 6],
        id: 4
    })
    .then(res => {
        console.log('TCL: res', res);
    })
    .catch(err => {
        console.log('TCL: err', err);
    });

License

MIT

Package Sidebar

Install

npm i mikudos-socketio-client

Weekly Downloads

2

Version

0.0.8

License

ISC

Unpacked Size

16.6 kB

Total Files

5

Last publish

Collaborators

  • yueguanyu