import nativeEventer from '../../common/nativeEventer';
import TOPICS from '../../const/topic';
import prepareHUYA from '../../common/prepareHUYA';
import messager from '../../common/messager';

const { DEV_MESSAGE } = TOPICS;

const eventer = new nativeEventer({ topic: `${DEV_MESSAGE}.dev-ext` });

export default {

  on(topic, callback) {
    return eventer.on(topic, callback);
  },

  off(topic, callback) {
    return eventer.off(topic, callback);
  },

  async emit(topic, message) {
    const { HUYA } = await prepareHUYA();
    const req = new HUYA.DeliverRoomMsgByUnionIdReq();
    req.event = topic;
    req.message = message;
    return messager.dispatchTaf('deliverRoomMsgByUnionId', req, HUYA.DeliverRoomMsgByUnionIdResp, 'extCapabilityUI');
  },
}




