2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
1.7 KiB

  1. #ifndef IZ_NET_CLIENT_H
  2. #define IZ_NET_CLIENT_H
  3. #include "minIni.h"
  4. #include "SDL_thread.h"
  5. #include "../config/IZ_config.h"
  6. #include "../common/IZ_common.h"
  7. #include "../game/input/IZ_action.h"
  8. #include "svc/IZ_wsclient.h"
  9. typedef enum {
  10. IZ_NET_CLIENT_STATUS_PRISTINE,
  11. IZ_NET_CLIENT_STATUS_CONNECTING,
  12. IZ_NET_CLIENT_STATUS_ERROR,
  13. IZ_NET_CLIENT_STATUS_CONNECTED,
  14. } IZ_NetClientStatus;
  15. typedef struct {
  16. u16 packet_interval_ms;
  17. u8 max_reconnect_retries;
  18. u8 reconnect_interval_secs;
  19. char username[32];
  20. } IZ_NetClientConfig;
  21. typedef struct {
  22. SDL_Thread* client_thread;
  23. IZ_NetClientConfig config;
  24. IZ_NetBinding binding;
  25. IZ_NetInitializeParams params;
  26. void* callback;
  27. IZ_Action action[IZ_PLAYERS];
  28. u8 retries;
  29. IZ_NetClientStatus status;
  30. // TODO add message queue
  31. } IZ_NetClientState;
  32. static IZ_NetClientState IZ_NET_CLIENT_DEFAULT_STATE = {
  33. .client_thread = NULL,
  34. .config = {
  35. .packet_interval_ms = 200,
  36. .max_reconnect_retries = 3,
  37. .reconnect_interval_secs = 3,
  38. .username = "Player",
  39. },
  40. .binding = {
  41. .interrupted = false,
  42. .context = NULL,
  43. .connection = NULL,
  44. .user_data = NULL,
  45. },
  46. .params = {
  47. .port = 42069,
  48. .path = "/",
  49. .host = "localhost",
  50. },
  51. .callback = NULL,
  52. .action = {},
  53. .retries = 3,
  54. .status = IZ_NET_CLIENT_STATUS_PRISTINE,
  55. };
  56. IZ_ProcedureResult IZ_NetClientInitialize(IZ_NetClientState*, void*, void*, const char *, u8, const char *[]);
  57. void IZ_NetClientConnect(IZ_NetClientState*, IZ_WSClientInitializeParams);
  58. void IZ_NetClientDisconnect(IZ_NetClientState*);
  59. IZ_ProcedureResult IZ_NetClientSaveConfig(IZ_NetClientState*, const char*);
  60. void IZ_NetClientSendBinaryMessage(IZ_NetClientState*, void*, size_t);
  61. void IZ_NetClientSendTextMessage(IZ_NetClientState*, char*, size_t);
  62. #endif