@akokko/blive-message-listener
Version:
Bilibili-live danmu listener with type
38 lines (35 loc) • 1.07 kB
JavaScript
import { listenAll } from "./listener-B76Rj76P.js";
import { KeepLiveTCP } from "tiny-bilibili-ws";
//#region src/types/const.ts
let GuardLevel = /* @__PURE__ */ function(GuardLevel$1) {
/** 无 */
GuardLevel$1[GuardLevel$1["None"] = 0] = "None";
/** 总督 */
GuardLevel$1[GuardLevel$1["Zongdu"] = 1] = "Zongdu";
/** 提督 */
GuardLevel$1[GuardLevel$1["Tidu"] = 2] = "Tidu";
/** 舰长 */
GuardLevel$1[GuardLevel$1["Jianzhang"] = 3] = "Jianzhang";
return GuardLevel$1;
}({});
//#endregion
//#region src/index.ts
const startListen = (roomId, handler, options) => {
const live = new KeepLiveTCP(roomId, options?.ws);
listenAll(live, roomId, handler);
const listenerInstance = {
live,
roomId: live.roomId,
online: live.online,
closed: live.closed,
close: () => live.close(),
getAttention: () => live.getOnline(),
getOnline: () => live.getOnline(),
reconnect: () => live.reconnect(),
heartbeat: () => live.heartbeat(),
send: (op, data) => live.send(op, data)
};
return listenerInstance;
};
//#endregion
export { GuardLevel, startListen };