mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-01-23 10:35:44 +00:00
Clean webrtc.js
This commit is contained in:
parent
dceb6f9993
commit
a013192bf8
1 changed files with 3 additions and 6 deletions
|
|
@ -98,27 +98,24 @@ const ice = (() => {
|
|||
onIceConnectionStateChange: () => {
|
||||
log.info('[rtc] <- iceConnectionState', connection.iceConnectionState);
|
||||
switch (connection.iceConnectionState) {
|
||||
case 'connected': {
|
||||
case 'connected':
|
||||
log.info('[rtc] connected...');
|
||||
connected = true;
|
||||
break;
|
||||
}
|
||||
case 'disconnected': {
|
||||
case 'disconnected':
|
||||
log.info(`[rtc] disconnected... ` +
|
||||
`connection: ${connection.connectionState}, ice: ${connection.iceConnectionState}, ` +
|
||||
`gathering: ${connection.iceGatheringState}, signalling: ${connection.signalingState}`)
|
||||
connected = false;
|
||||
pub(WEBRTC_CONNECTION_CLOSED);
|
||||
break;
|
||||
}
|
||||
case 'failed': {
|
||||
case 'failed':
|
||||
log.error('[rtc] failed establish connection, retry...');
|
||||
connected = false;
|
||||
connection.createOffer({iceRestart: true})
|
||||
.then(description => connection.setLocalDescription(description).catch(log.error))
|
||||
.catch(log.error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue