0.0.14 • Published 6 years ago

minarai-client-sdk-js-websocket v0.0.14

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

minarai client SDK (for JavaScript/WebSocket)

Description

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

Requirement

Install

on your project root npm install -S Nextremer/minarai-client-sdk-js-websocket or yarn add https://github.com/Nextremer/minarai-client-sdk-js-websocket.git

Usage

import MinaraiClient from 'minarai-client-sdk-js-websocket';

const minaraiClient = new MinaraiClient({
  ws: WebSocket,
  lang: 'ja-JP',
  websocketRootURL: 'ws://localhost:3000/ws', /* minarai WebSocket Connector URL */
  websocketOptions: [], /* options for WebSocket https://developer.mozilla.org/ja/docs/Web/API/WebSocket */
  applicationId: this.state.connectionInfo.applicationId, /* application's id you want to connect */
  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("## websocket connected. trying to join as minarai client");
});
minaraiClient.on('joined', function(){
  console.log("## minarai CONNECTED");
});
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

  • ws: WebSocket Object
  • lang: language option( default: "ja-JP" )
  • websocketRootURL: root url of minarai WebSocket Connector
  • websocketOptions: options for io.connect method (ex) {}
  • applicationId: application id 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: message to send
      • 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
  • 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.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

6 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