Skip to content

Commit

Permalink
fix: JoinChannelSuccess RejoinChannelSuccess type in `RtcChannelE…
Browse files Browse the repository at this point in the history
…vents`
  • Loading branch information
LichKing-2234 committed Oct 23, 2020
1 parent 6f74266 commit 25cf253
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions example/src/examples/advanced/MultiChannel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class MultiChannel extends Component<{}, State, any> {
}

this._channel0 = await RtcChannel.create(channelId0);
this._addListener(this._channel0, channelId0);
this._addListener(this._channel0);

await this._channel0.setClientRole(ClientRole.Broadcaster);
await this._channel0.joinChannel(
Expand All @@ -90,7 +90,7 @@ export default class MultiChannel extends Component<{}, State, any> {
}

this._channel1 = await RtcChannel.create(channelId1);
this._addListener(this._channel1, channelId1);
this._addListener(this._channel1);

await this._channel1.setClientRole(ClientRole.Broadcaster);
await this._channel1.joinChannel(
Expand All @@ -101,24 +101,25 @@ export default class MultiChannel extends Component<{}, State, any> {
);
};

_addListener = (channel: RtcChannel, channelId: string) => {
channel.addListener('JoinChannelSuccess', (uid, elapsed) => {
console.info('JoinChannelSuccess', channelId, uid, elapsed);
_addListener = (rtcChannel: RtcChannel) => {
const { channelId } = rtcChannel;
rtcChannel.addListener('JoinChannelSuccess', (channel, uid, elapsed) => {
console.info('JoinChannelSuccess', channel, uid, elapsed);
if (channelId === channelId0) {
this.setState({ isJoined0: true });
} else if (channelId === channelId1) {
this.setState({ isJoined1: true });
}
});
channel.addListener('UserJoined', (uid, elapsed) => {
rtcChannel.addListener('UserJoined', (uid, elapsed) => {
console.info('UserJoined', channelId, uid, elapsed);
if (channelId === channelId0) {
this.setState({ remoteUid0: uid });
} else if (channelId === channelId1) {
this.setState({ remoteUid1: uid });
}
});
channel.addListener('UserOffline', (uid, reason) => {
rtcChannel.addListener('UserOffline', (uid, reason) => {
console.info('UserOffline', channelId, uid, reason);
if (channelId === channelId0) {
if (uid === this.state.remoteUid0) {
Expand All @@ -130,7 +131,7 @@ export default class MultiChannel extends Component<{}, State, any> {
}
}
});
channel.addListener('LeaveChannel', (stats) => {
rtcChannel.addListener('LeaveChannel', (stats) => {
console.info('LeaveChannel', channelId, stats);
if (channelId === channelId0) {
this.setState({ isJoined0: false, remoteUid0: undefined });
Expand Down
4 changes: 2 additions & 2 deletions src/common/RtcEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ export interface RtcChannelEvents {
*
* @event JoinChannelSuccess
*/
JoinChannelSuccess: UidWithElapsedCallback;
JoinChannelSuccess: UidWithElapsedAndChannelCallback;

/**
* Occurs when a user rejoins the channel after being disconnected due to network problems.
Expand All @@ -1419,7 +1419,7 @@ export interface RtcChannelEvents {
*
* @event RejoinChannelSuccess
*/
RejoinChannelSuccess: UidWithElapsedCallback;
RejoinChannelSuccess: UidWithElapsedAndChannelCallback;

/**
* Occurs when a user leaves the channel.
Expand Down

0 comments on commit 25cf253

Please sign in to comment.