Partially finished client
This commit is contained in:
33
src/main.c
33
src/main.c
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "console/console.h"
|
||||
#include "client/client.h"
|
||||
#include "server/server.h"
|
||||
#include "util/string.h"
|
||||
#include "assert/assert.h"
|
||||
@ -16,41 +17,13 @@ void cmdExit(const consolecmdexec_t *exec) {
|
||||
exitRequested = true;
|
||||
}
|
||||
|
||||
void cmdServe(const consolecmdexec_t *exec) {
|
||||
uint16_t port = 3030;
|
||||
if(exec->argc != 0) {
|
||||
if(!stringToU16(exec->argv[0], &port)) {
|
||||
consolePrint("Invalid port number: %s", exec->argv[0]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
errorret_t ret = serverStart((serverstart_t){
|
||||
.type = SERVER_TYPE_NETWORKED,
|
||||
.networked = {
|
||||
.port = 3030
|
||||
}
|
||||
});
|
||||
|
||||
if(ret != ERROR_OK) {
|
||||
consolePrint("Failed to start server: %s", errorString());
|
||||
errorFlush();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void cmdClose(const consolecmdexec_t *exec) {
|
||||
serverStop();
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
assertInit();
|
||||
consoleInit();
|
||||
clientInit();
|
||||
serverInit();
|
||||
|
||||
consoleRegCmd("exit", cmdExit);
|
||||
consoleRegCmd("serve", cmdServe);
|
||||
consoleRegCmd("close", cmdClose);
|
||||
|
||||
InitWindow(1280, 720, DUSK_NAME);
|
||||
|
||||
@ -68,7 +41,9 @@ int main(void) {
|
||||
}
|
||||
|
||||
CloseWindow();
|
||||
|
||||
serverDispose();
|
||||
clientDispose();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Reference in New Issue
Block a user