egame-ws-client

1.0.5 • Public • Published

说明


本脚本只用于通过ws对企鹅电竞进行弹幕拉取。

本脚本依赖tars提供弹幕解码支持

how to use

// install
npm i -S egame-ws-client

// useage

const connect = require('egame-ws-client')

connect({
    roomId: 132214784,
    egameId: 'egame_official'
}, function (err, eventList) {
    if (!err) {
        eventList.map(event => {
            console.log(`result:${event.event_id}`)
            event.msg_list.map(msg => {
                console.log(`${msg.msgid}|${msg.nick}[${msg.uid}]:${msg.content}`)
            })
        })
    } else {
        console.error('connect err', err)
    }
}).then(client=>{
    // ws client 的实例。
})

参数说明

  • roomId: 需要拉取的房间号
  • egameId: 用于区分上报

回调参数说明

  • err : 错误信息
  • eventList: 一次拉取的结构体,里面可能会有1个,或者多个event
    • event: 一次弹幕汇总的结构体
      • event.event_id: 用于唯一标识本次弹幕汇总
      • event.msg_list: 弹幕集合
        • msg.msgid: 弹幕的唯一标识
        • msg.nick:弹幕发送的用户名
        • msg.content: 弹幕发送的内容

返回参数 @support 1.0.4

connect 是一个 async 函数,可以使用await的形式,也可以使用 promise的形式,来获取实例化的ws client。

运行环境

需要node版本大于等于8.0.0

Readme

Keywords

none

Package Sidebar

Install

npm i egame-ws-client

Weekly Downloads

1

Version

1.0.5

License

ISC

Unpacked Size

54.5 kB

Total Files

18

Last publish

Collaborators

  • egamedev