@gdyfe/elcps-msg

ELCPS's Message framework

Usage no npm install needed!

<script type="module">
  import gdyfeElcpsMsg from 'https://cdn.skypack.dev/@gdyfe/elcps-msg';
</script>

README

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