Basic protocol structure on the server side

This commit is contained in:
2025-09-28 11:09:26 +02:00
parent 0ade2938f3
commit b69cabfab8
9 changed files with 412 additions and 75 deletions
+56
View File
@@ -0,0 +1,56 @@
/*
LibreFront --- an OpenFront clone
Copyright (C) 2025 Adrien Jaguenet
Copyright (C) 2025 Emil Kosz
This program 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.
This program 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <glib.h>
#include "ClientRequest.h"
#include "ServerResponse.h"
#define PROTOCOL_VERSION 0x1
typedef enum {
RESPONSE_ERROR = 0xffffffff,
} ResponseType;
typedef enum {
REQUEST_HELLO = 0x00000001,
REQUEST_JOINGAME = 0x00000002,
} RequestType;
typedef struct {
guint32 version;
guint32 type;
guint32 data_size;
} MessageHeader;
typedef struct {
MessageHeader header;
void* data;
} Message;
/* @param stream: input stream (from a socket ideally)
* @param message: message structure that will be read into
* @return -1 on error
* */
int Message_read(GInputStream* stream, Message* message);