0.1.1 • Published 5 years ago

minarai-client-sdk-js-socket-io v0.1.1

Weekly downloads
12
License
MIT
Repository
github
Last release
5 years ago

minarai client SDK (for JavaScript/Socket.io)

Description

A SDK that enables you to connect minarai easily on Node.js, browser both.

Requirement

Install

Using npm:

npm install -S minarai-client-sdk-js-socket-io

Using yarn:

yarn add minarai-client-sdk-js-socket-io

Usage

const io = require("socket.io-client");
const MinaraiClient = require("minarai-client-sdk-js-socket.io").default;

// For ES2015~
// import io from 'socket.io-client';
// import MinaraiClient from 'minarai-client-sdk-js-socket-io';

const minaraiClient = new MinaraiClient({
  io: io, /* Socket.io object */
  applicationId: this.state.connectionInfo.applicationId, /* application's id you want to connect */
  applicationSecret : this.state.connectionInfo.applicationSecret,
  clientId: this.state.connectionInfo.clientId,
  userId: this.state.connectionInfo.userId,
  deviceId: this.state.connectionInfo.deviceId,
});

minaraiClient.init();

// binding events
minaraiClient.on('connect', function(){
  console.log("## socket.io connected. trying to join as minarai client");
});
minaraiClient.on('joined', function(){
  console.log("## minarai joined");
});
minaraiClient.on( "message", function( data ){
  console.log("recieve message");
  console.log(data)
});
minaraiClient.on( "error", function( err ){
  console.log("minarai client error");
  console.log(err);
});

// send message "hello" to dialogue-hub every 3 seconds
setInterval( function(){
  minaraiClient.send("hello");
}, 3000 );

references

constructor options

  • io: socket.io object
  • lang: language option ( default: "ja-JP" )
  • socketIORootURL: root url of minarai Socket.IO Connector ( default: "https://socketio-connector.minarai.cloud" )
  • socketIOOptions: options for io.connect method (ex) {}
  • apiVersion: api version of minarai Socket.IO Connector ( default: "v1" )
  • applicationId: application id to connect
  • applicationSecret: application secret to connect
  • clientId: clientId
  • userId: userId
  • deviceId: deviceId
  • debug : set true to show debug logs
  • slient : set true value to hide all the logs

methods

  • send: send message to minarai
    • arguments
      • uttr: string/object: message to send
        • if you pass an object, sdk sends it as is to minarai.
      • options :
        • lang: string: language option. ex: 'ja-JP'
        • extra: any: you can pass extra info to minarai.
  • sendSystemCommand: send system command to minarai
    • arguments
      • command: string
      • payload: any
cli.send('hello', { lang: 'ja-JP', extra: {} });
cli.sendSystemCommand('happyEmotionDetected', { value: true });

events

  • connect: when connected to minarai successfully
  • joined: when signed in to minarai as client successfully
  • join-failed: when signing in to minarai was failed
  • disconnected: when disconnected to minarai successfully
  • sync: when you or your group send message to minarai(for sync message between multiple devices)
  • sync-system-command: when you or your group send system command to minarai(for sync system command between multiple devices)
  • message: when minarai send any event
0.1.1

5 years ago

0.1.0

5 years ago

0.0.26

5 years ago

0.0.24

6 years ago

0.0.23

6 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.18

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago