blob: d545c311daaf5b97f5739ca6c35d6729eb09403f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
function start() {
game.mode = Game.HostMode
startViewLoader.item.showStartServerDialog("Creating server")
// gameHosts only exists after game.mode is set to Game.HostMode
gameHost.statusChanged.connect(onStatusChanged)
gameHost.startConnection()
}
function quit() {
gameHost.statusChanged.disconnect(onStatusChanged)
startViewLoader.item.hideStartServerDialog()
gameHost.quit();
}
function onStatusChanged() {
switch (gameHost.status) {
case GameHost.Start:
startViewLoader.item.hideStartServerDialog()
hostViewLoader.source = "HostView.qml"
break
case GameHost.Error:
startViewLoader.item.hideStartServerDialog()
handleError(gameHost.error)
break
default:
console.log("Unknown server status")
}
}
function handleError(error) {
switch (error) {
case GameHost.AnotherServerRunningError:
startViewLoader.item.showErrorDialog("Server is already running")
break
default:
console.log("Unknown server error")
}
}
|