Skip to content

Commit

Permalink
fix(rtc): 修复无法在语音会话中切换频道的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed May 23, 2021
1 parent 1658174 commit 34db8ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 6 additions & 8 deletions src/rtc/RoomClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,6 @@ export class RoomClient {

logger.debug('close()');

// Close protoo Peer
if (!_isNil(this._protoo)) {
this._protoo.close();
}

await this.disableAll();

{
Expand All @@ -266,6 +261,11 @@ export class RoomClient {
this._recvTransport.close();
}

// Close protoo Peer
if (!_isNil(this._protoo)) {
this._protoo.close();
}

store.dispatch(stateActions.setRoomId(null));
store.dispatch(stateActions.setRoomState('closed'));
}
Expand Down Expand Up @@ -1375,9 +1375,7 @@ export class RoomClient {

store.dispatch(stateActions.setAudioOnlyInProgress(true));

const devices = (await settingManager.getDevices()) || {
webcamEnabled: false,
};
const devices = await settingManager.getDevices();

if (!this._webcamProducer && this._produce && devices.webcamEnabled) {
this.enableWebcam();
Expand Down
6 changes: 3 additions & 3 deletions src/rtc/RoomContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ const initRoomClientStore = () => {
export const RTCRoomClientContextProvider: React.FC = TMemo((props) => {
const [client, setClient] = useState<RoomClient>();

const deleteClient = useCallback(() => {
const deleteClient = useCallback(async () => {
if (!_isNil(client)) {
trackEvent('rtc:leaveRoom', {
roomId: client.roomId,
});
client.close();
await client.close();
}

setClient(undefined);
Expand All @@ -46,7 +46,7 @@ export const RTCRoomClientContextProvider: React.FC = TMemo((props) => {

if (!_isNil(client)) {
// 关闭上一个连接
deleteClient();
await deleteClient();
}

trackEvent('rtc:joinRoom', {
Expand Down

0 comments on commit 34db8ab

Please sign in to comment.