@akokko/blive-message-listener
Version:
Bilibili-live danmu listener with type
24 lines (22 loc) • 668 B
JavaScript
import { listenAll } from "./listener-B76Rj76P.js";
import { KeepLiveWS } from "tiny-bilibili-ws/browser";
//#region src/browser.ts
const startListen = (roomId, handler, options) => {
const live = new KeepLiveWS(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 { startListen };