0.1.2 • Published 4 years ago

@gdyfe/elcps-msg v0.1.2

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

ELCPS-MSG

ELCPS's Message framework

Install

NPM(Recommended)

sudo npm install @gdyfe/elcps-msg --save
sudo yarn add @gdyfe/elcps-msg

Browser

Coming soon

Usage

Initialize

const websocketAddress = 'ws://xxx.xxx.xxx.xxx:xxxx'
const msgHandler = new LcpsMsg(websocketAddress, instanceId, msgCallback, reconnectSuccessCallback)

Send

Method: LcpsMsg.Send(msg: TMsg): void

type TMsg = {
  server: string
  data: {
    cmd: string
    data?: any
  }
} | string

Example:

const res = await msgHandler.Send(msg)

Close

Method: LcpsMsg.Close(): void