sendMessage 方法

作用:

给已连接的设备发送文本信息 (命令)。

原型:

interface CoolinkRetCode {
  code: number;
  msg?: string;
}

function sendMessage(contentName: string, content: string): Promise<CoolinkRetCode>;

参数:

属性类型说明解释
contentstringJSON格式字符串JSON 格式字符串的发送内容
contentNamestring内容的名称内容的名称

返回值:

属性类型说明解释
codenumber错误码表示是否发生错误的一个数字,没有错误则为 0
msgstring错误信息文本表示是否发生错误的一个字符串描述,可选

范例:

import { coolink } from 'coolink';

coolink.protocol.sendMessage(
  'content1',
  JSON.stringify({
    command: 'show',
    url: 'https://xxxxxxx'
  })
);

//
Last Updated:
Contributors: liangquanqing, wangyong-debug
©深圳市酷开网络科技股份有限公司 ICP备案号粤ICP备06098778号