agora-react-native-rtm
Version:
React Native around the Agora RTM SDKs for Android and iOS agora
133 lines (132 loc) • 4.92 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StreamChannelInternal = void 0;
var _AgoraRtmBase = require("../legacy/AgoraRtmBase");
var _IAgoraStreamChannel = require("../legacy/IAgoraStreamChannel");
var _IAgoraStreamChannelImpl = require("../legacy/impl/IAgoraStreamChannelImpl");
var _IrisRtmEngine = require("./IrisRtmEngine");
class StreamChannelInternal extends _IAgoraStreamChannelImpl.IStreamChannelImpl {
_channelName = '';
constructor(channelName) {
super();
console.log('create streamChannel', channelName);
this._channelName = channelName;
}
get channelName() {
return this._channelName;
}
join(options) {
let operation = 'join';
let callBack = 'onJoinResult';
try {
const status = super.join(options);
return (0, _IrisRtmEngine.wrapRtmResult)(status, operation, callBack);
} catch (error) {
throw (0, _IrisRtmEngine.handleError)(error, operation);
}
}
leave() {
let operation = 'leave';
let callBack = 'onLeaveResult';
try {
const status = super.leave();
return (0, _IrisRtmEngine.wrapRtmResult)(status, operation, callBack);
} catch (error) {
throw (0, _IrisRtmEngine.handleError)(error, operation);
}
}
async joinTopic(topicName, options) {
let operation = 'joinTopic';
let callBack = 'onJoinTopicResult';
try {
const status = super.joinTopic(topicName, options ? options : new _IAgoraStreamChannel.JoinTopicOptions());
let result = await (0, _IrisRtmEngine.wrapRtmResult)(status, operation, callBack);
return {
...result,
topicName
};
} catch (error) {
throw (0, _IrisRtmEngine.handleError)(error, operation);
}
}
async publishTopicMessage(topicName, message, options) {
let operation = 'publishTopicMessage';
let callBack = 'onPublishTopicMessageResult';
try {
const status = super.publishTopicMessage(topicName, message, options ? options : new _AgoraRtmBase.TopicMessageOptions());
let result = await (0, _IrisRtmEngine.wrapRtmResult)(status, operation, callBack);
return {
...result,
topicName
};
} catch (error) {
throw (0, _IrisRtmEngine.handleError)(error, operation);
}
}
async leaveTopic(topicName) {
let operation = 'leaveTopic';
let callBack = 'onLeaveTopicResult';
try {
const status = super.leaveTopic(topicName);
let result = await (0, _IrisRtmEngine.wrapRtmResult)(status, operation, callBack);
return {
...result,
topicName
};
} catch (error) {
throw (0, _IrisRtmEngine.handleError)(error, operation);
}
}
async subscribeTopic(topicName, options) {
let operation = 'subscribeTopic';
let callBack = 'onSubscribeTopicResult';
try {
var _result$callBackResul, _result$callBackResul2;
const status = super.subscribeTopic(topicName, options ? options : new _IAgoraStreamChannel.TopicOptions());
let result = await (0, _IrisRtmEngine.wrapRtmResult)(status, operation, callBack, true);
return {
succeedUsers: (_result$callBackResul = result.callBackResult) === null || _result$callBackResul === void 0 ? void 0 : _result$callBackResul.succeedUsers,
failedUsers: (_result$callBackResul2 = result.callBackResult) === null || _result$callBackResul2 === void 0 ? void 0 : _result$callBackResul2.failedUsers,
timestamp: result.timestamp,
topicName
};
} catch (error) {
throw (0, _IrisRtmEngine.handleError)(error, operation);
}
}
async unsubscribeTopic(topicName, options) {
let operation = 'unsubscribeTopic';
let callBack = 'onUnsubscribeTopicResult';
try {
const status = super.unsubscribeTopic(topicName, options ? options : new _IAgoraStreamChannel.TopicOptions());
let result = await (0, _IrisRtmEngine.wrapRtmResult)(status, operation, callBack);
return result;
} catch (error) {
throw (0, _IrisRtmEngine.handleError)(error, operation);
}
}
async getSubscribedUserList(topicName) {
let operation = 'getSubscribedUserList';
let callBack = 'onGetSubscribedUserListResult';
try {
var _result$callBackResul3;
const status = super.getSubscribedUserList(topicName, 0);
let result = await (0, _IrisRtmEngine.wrapRtmResult)(status, operation, callBack, true);
return {
subscribed: (_result$callBackResul3 = result.callBackResult) === null || _result$callBackResul3 === void 0 ? void 0 : _result$callBackResul3.users,
topicName,
timestamp: result.timestamp
};
} catch (error) {
throw (0, _IrisRtmEngine.handleError)(error, operation);
}
}
release() {
const ret = super.release();
return ret;
}
}
exports.StreamChannelInternal = StreamChannelInternal;
//# sourceMappingURL=StreamChannelInternal.js.map