/** * Copyright (c) 2025 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #include "packet.h" #include "util/memory.h" #include "assert/assert.h" #include "server/server.h" void packetPingCreate(packet_t *packet) { packetInit(packet, PACKET_TYPE_PING, sizeof(packetping_t)); packet->data.ping.number = GetRandomValue(0, INT32_MAX); } errorret_t packetPingClientProcess( const packet_t *packet, client_t *client ) { printf("Client got Pong!\n"); return ERROR_OK; } errorret_t packetPingServerProcess( const packet_t *packet, serverclient_t *client ) { if(packet->length != sizeof(packetping_t)) { return error("Ping packet length is not %d", sizeof(packetping_t)); } printf("Server got Ping!\n"); packet_t pong; packetPingCreate(&pong); packetQueuePushOut(&client->packetQueue, &pong); return ERROR_OK; }