-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.R
83 lines (73 loc) · 2.96 KB
/
server.R
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
## Copyright 2015,2016,2017,2018,2019 Institut National de la Recherche Agronomique
## and Montpellier SupAgro.
##
## This file is part of PlantBreedGame.
##
## PlantBreedGame is free software: you can redistribute it and/or modify
## it under the terms of the GNU Affero General Public License as
## published by the Free Software Foundation, either version 3 of the
## License, or (at your option) any later version.
##
## PlantBreedGame is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU Affero General Public
## License along with PlantBreedGame. If not, see
## <http://www.gnu.org/licenses/>.
source("src/dependencies.R", local = TRUE, encoding = "UTF-8")$value
shinyServer(function(input, output, session) {
currentGTime <- reactive({
## this variable contain the game time.
## it is reevaluated every 250 milliseconds
## send a "tic" message to the client to get information about the server status (busy or not)
invalidateLater(250)
session$sendCustomMessage("serverTic", "tic")
getGameTime()
})
values <- reactiveValues(
lastDBupdate = Sys.time()
)
gameInitialised <- function() {
(dir.exists(DATA_TRUTH) &
dir.exists(DATA_SHARED) &
dir.exists(DATA_INITIAL_DATA) &
dir.exists(DATA_REPORTS) &
file.exists(DATA_DB))
}
observe({
if (!gameInitialised()) {
msg <- paste(
"The game have not been initialised. It is therefore currently impossible to play.",
'\nTo initialise the game, go to the "Admin" menu and in the "Game setup" tab.',
"From there you will be able to initialise a new game."
)
alert(msg)
}
})
source("src/server/server_information.R", local = TRUE, encoding = "UTF-8")$value
source("src/server/server_id.R", local = TRUE, encoding = "UTF-8")$value
source("src/server/server_plant_material.R", local = TRUE, encoding = "UTF-8")$value
source("src/server/server_pheno.R", local = TRUE, encoding = "UTF-8")$value
source("src/server/server_geno.R", local = TRUE, encoding = "UTF-8")$value
source("src/server/server_data_viz.R", local = TRUE, encoding = "UTF-8")$value
source("src/server/server_eval.R", local = TRUE, encoding = "UTF-8")$value
source("src/server/server_theory.R", local = TRUE, encoding = "UTF-8")$value
source("src/server/server_admin.R", local = TRUE, encoding = "UTF-8")$value
source("src/server/server_about.R", local = TRUE, encoding = "UTF-8")$value
source("src/server/server_constants.R", local = TRUE, encoding = "UTF-8")$value
# some reactive values used at different places:
constantsReactive <- reactivePoll(
5000,
session,
function() {
if (file.exists(DATA_DB)) {
file.info(DATA_DB)$mtime[1]
} else {
""
}
},
getBreedingGameConstants
)
})