#pragma once #include #include #include #include #include #include #include "engine.h" #include "utils.h" /** * @brief Server Listen and Server Ip's */ #define DEFAULT_IP "35.157.44.223" //AWS_IP #define DEFAULT_IP_BIN 0x239d2cdf //Precomputed because arpa/inet.h is not available /** * @brief default port for UDP/TCP communication */ #define DEFAULT_PORT 27500 /*typedef struct { u16 addraddr; u16 addr; } saddr_t;*/ typedef struct sockaddr_in saddr_t; typedef enum {INVALID = -1, NAME, GSTART, ACTION} client_message_t; /** ====================================================================== * @brief Initializes and connects to WIFI * @return error */ s16 init_wlpif(); /** ====================================================================== * @brief get a socket for communication and sets its reception timeout * @param receive timeout in seconds, 0 means infinity (no timeout) * @return error */ s16 init_socket(const s16 receive_timeout_in_seconds); /** ====================================================================== * @brief Cleans up a socket */ void end_socket(); /** ====================================================================== * @brief Disconnects from wifi */ void end_wlpif(); // VARIOUS FUNCTIONS s32 net_snd(char* data_buff, s32 bytes); s32 net_rcv(char* data_buff, s32 bytes); bool rcv_room_from_server(char* data_buff, s32 bytes, gs_t* const game_status);