mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-19 09:34:12 +00:00
Use audioReady
This commit is contained in:
parent
5f373c932f
commit
7d2bd2f698
2 changed files with 11 additions and 3 deletions
2
static/js/global.js
vendored
2
static/js/global.js
vendored
|
|
@ -59,6 +59,8 @@ let menuTop = MENU_TOP_POSITION;
|
|||
let isLayoutSwitched = false;
|
||||
|
||||
var gameReady = false;
|
||||
var inputReady = false;
|
||||
var audioReady = false;
|
||||
var iceSuccess = true;
|
||||
var iceSent = false; // TODO: set to false in some init event
|
||||
var defaultICE = [{urls: "stun:stun.l.google.com:19302"}]
|
||||
|
|
|
|||
12
static/js/ws.js
vendored
12
static/js/ws.js
vendored
|
|
@ -110,7 +110,10 @@ function startWebRTC() {
|
|||
negotiated: true,
|
||||
id: 0,
|
||||
});
|
||||
inputChannel.onopen = () => log('inputChannel has opened');
|
||||
inputChannel.onopen = () => {
|
||||
log('inputChannel has opened');
|
||||
inputReady = true;
|
||||
}
|
||||
inputChannel.onclose = () => log('inputChannel has closed');
|
||||
|
||||
|
||||
|
|
@ -155,7 +158,10 @@ function startWebRTC() {
|
|||
id: 1,
|
||||
maxRetransmits: 0
|
||||
})
|
||||
audioChannel.onopen = () => log('audioChannel has opened');
|
||||
audioChannel.onopen = () => {
|
||||
log('audioChannel has opened');
|
||||
audioReady = true;
|
||||
}
|
||||
audioChannel.onclose = () => log('audioChannel has closed');
|
||||
|
||||
audioChannel.onmessage = (e) => {
|
||||
|
|
@ -243,7 +249,7 @@ function startGame() {
|
|||
return;
|
||||
}
|
||||
// TODO: Add while loop
|
||||
if (!gameReady) {
|
||||
if (!gameReady || !inputReady || !audioReady) {
|
||||
popup("Game is not ready yet. Please wait");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue