c3-client
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

c3-client

这是用于rpcMehod调用的客户端类

依赖

{
    "rpc-websockets": "^7.4.16",
    "c3-util": "^1.0.0",
  }

RpcClient类

用于启动ws Client连接,这个类必须优先调用否则后面的rpcMethod相关类无法调用

  • 方法
import { RpcClient } from 'c3-client'
//启动
RpcClient.start('ws://127.0.0.1:11000')
//关闭
RpcClient.close()

RpcSoaService类

调用soa相关服务类

  • example
import {RpcClient, RpcSoaService} from '../src'
import TestUtil from './TestUtil'
test('soaService test',async ()=>{
    RpcClient.start('ws://192.168.0.17:11000')
    await TestUtil.sleep(1000)
    //imrCheck
    let c3ImrCheckResp=await RpcSoaService.c3ImrCheck('18959130026','WINDOES')
    expect(c3ImrCheckResp.success()).toBe(true)
    const phoneNbrOption=c3ImrCheckResp.getFirstTableColumnValue('phone_nbr')
    expect(phoneNbrOption.isPresent()).toBe(true)
    expect(phoneNbrOption.get()).toBe('18959130026')
    //checkServer
    const checkServerTest=await RpcSoaService.checkServerTest('192.168.0.17',8080)
    expect(checkServerTest.success()).toBe(true)
    const firstTableOption=checkServerTest.getFirstTableRowObj()
    expect(firstTableOption.isPresent()).toBe(true)
    expect(firstTableOption.get().data_center).toBe('演示环境')
    // call C3_GetSpdnUrlByTerm
    const spdnUrlByTermResp=await RpcSoaService.callService('C3_GetSpdnUrlByTerm',{
        term_serial_no:'18959130026',
        client_type:'WINDOWS'
    })
    expect(spdnUrlByTermResp.success()).toBe(true)
    //获取多行返回
    const firstTablesOption=spdnUrlByTermResp.getFirstTableMultiRowObj()
    expect(firstTablesOption.isPresent()).toBe(true)
    //内网终端
    expect(firstTablesOption.get()[0].internet_flag).toBe('0')
    RpcClient.close()
    await TestUtil.sleep(500)
})

Dependencies (1)

Dev Dependencies (6)

Package Sidebar

Install

npm i c3-client

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

36.8 kB

Total Files

19

Last publish

Collaborators

  • fjlinhua