@gdyfe/elcps-rpc
v0.1.1
Published
ELCPS's RPC communication framework
Downloads
5
Readme
ELCPS-RPC
ELCPS's RPC communication framework
Install
NPM(Recommended)
sudo npm install @gdyfe/elcps-rpc --save
sudo yarn add @gdyfe/elcps-rpc
Browser
Coming soon
Usage
Initialize
const websocketAddress = 'ws://xxx.xxx.xxx.xxx:xxxx'
const rpc = new LcpsRpc(websocketAddress)
Request
Method: LcpsRpc.Request(msg: TMsg): Promise<TResult>
type TMsg = {
server: string
data: {
cmd: string
data?: any
}
}
type TResult = {
code: string
message: string
data?: any
}
Example:
const res = await rpc.Request({
server: instanceId,
data: {
cmd: 'setConfig',
config: data
}
})
data.cmd
fields support many types: getConfig
, setConfig
Close
Method: LcpsRpc.Close(): void