@@ -26,6 +26,7 @@ import (
26
26
"github.com/mmp/vice/pkg/platform"
27
27
"github.com/mmp/vice/pkg/rand"
28
28
"github.com/mmp/vice/pkg/renderer"
29
+ "github.com/mmp/vice/pkg/server"
29
30
"github.com/mmp/vice/pkg/sim"
30
31
"github.com/mmp/vice/pkg/util"
31
32
43
44
logLevel = flag .String ("loglevel" , "info" , "logging level: debug, info, warn, error" )
44
45
logDir = flag .String ("logdir" , "" , "log file directory" )
45
46
lintScenarios = flag .Bool ("lint" , false , "check the validity of the built-in scenarios" )
46
- server = flag .Bool ("runserver" , false , "run vice scenario server" )
47
- serverPort = flag .Int ("port" , sim .ViceServerPort , "port to listen on when running server" )
48
- serverAddress = flag .String ("server" , sim .ViceServerAddress + fmt .Sprintf (":%d" , sim .ViceServerPort ), "IP address of vice multi-controller server" )
47
+ runServer = flag .Bool ("runserver" , false , "run vice scenario server" )
48
+ serverPort = flag .Int ("port" , server .ViceServerPort , "port to listen on when running server" )
49
+ serverAddress = flag .String ("server" , server .ViceServerAddress + fmt .Sprintf (":%d" , server .ViceServerPort ), "IP address of vice multi-controller server" )
49
50
scenarioFilename = flag .String ("scenario" , "" , "filename of JSON file with a scenario definition" )
50
51
videoMapFilename = flag .String ("videomap" , "" , "filename of JSON file with video map definitions" )
51
52
broadcastMessage = flag .String ("broadcast" , "" , "message to broadcast to all active clients on the server" )
@@ -76,7 +77,7 @@ func main() {
76
77
}
77
78
78
79
// Initialize the logging system first and foremost.
79
- lg := log .New (* server , * logLevel , * logDir )
80
+ lg := log .New (* runServer , * logLevel , * logDir )
80
81
81
82
profiler , err := util .CreateProfiler (* cpuprofile , * memprofile )
82
83
if err != nil {
@@ -85,7 +86,7 @@ func main() {
85
86
defer profiler .Cleanup ()
86
87
87
88
if * serverAddress != "" && ! strings .Contains (* serverAddress , ":" ) {
88
- * serverAddress += fmt .Sprintf (":%d" , sim .ViceServerPort )
89
+ * serverAddress += fmt .Sprintf (":%d" , server .ViceServerPort )
89
90
}
90
91
91
92
if * lintScenarios {
@@ -128,9 +129,9 @@ func main() {
128
129
}
129
130
os .Exit (0 )
130
131
} else if * broadcastMessage != "" {
131
- sim .BroadcastMessage (* serverAddress , * broadcastMessage , * broadcastPassword , lg )
132
- } else if * server {
133
- sim .RunServer (* scenarioFilename , * videoMapFilename , * serverPort , lg )
132
+ server .BroadcastMessage (* serverAddress , * broadcastMessage , * broadcastPassword , lg )
133
+ } else if * runServer {
134
+ server .RunServer (* scenarioFilename , * videoMapFilename , * serverPort , lg )
134
135
} else if * showRoutes != "" {
135
136
if err := av .PrintCIFPRoutes (* showRoutes ); err != nil {
136
137
lg .Errorf ("%s" , err )
@@ -165,13 +166,13 @@ func main() {
165
166
166
167
config , configErr := LoadOrMakeDefaultConfig (lg )
167
168
168
- var controlClient * sim .ControlClient
169
- var mgr * sim .ConnectionManager
169
+ var controlClient * server .ControlClient
170
+ var mgr * server .ConnectionManager
170
171
var err error
171
172
var simErrorLogger util.ErrorLogger
172
- mgr , err = sim .MakeServerConnection (* serverAddress , * scenarioFilename , * videoMapFilename ,
173
+ mgr , err = server .MakeServerConnection (* serverAddress , * scenarioFilename , * videoMapFilename ,
173
174
& simErrorLogger , lg ,
174
- func (c * sim .ControlClient ) { // updated client
175
+ func (c * server .ControlClient ) { // updated client
175
176
if c != nil {
176
177
panes .ResetSim (config .DisplayRoot , c , c .State , plat , lg )
177
178
}
@@ -180,15 +181,15 @@ func main() {
180
181
},
181
182
func (err error ) {
182
183
switch err {
183
- case sim .ErrRPCVersionMismatch :
184
+ case server .ErrRPCVersionMismatch :
184
185
ShowErrorDialog (plat , lg ,
185
186
"This version of vice is incompatible with the vice multi-controller server.\n " +
186
187
"If you're using an older version of vice, please upgrade to the latest\n " +
187
188
"version for multi-controller support. (If you're using a beta build, then\n " +
188
189
"thanks for your help testing vice; when the beta is released, the server\n " +
189
190
"will be updated as well.)" )
190
191
191
- case sim .ErrServerDisconnected :
192
+ case server .ErrServerDisconnected :
192
193
ShowErrorDialog (plat , lg , "Lost connection to the vice server." )
193
194
uiShowConnectDialog (mgr , false , config , plat , lg )
194
195
0 commit comments