2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

IZ_net_client.h 1.8 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 usernames[IZ_PLAYERS][32];
  20. } IZ_NetClientConfig;
  21. typedef struct {
  22. void* 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. .thread = NULL,
  34. .config = {
  35. .packet_interval_ms = 200,
  36. .max_reconnect_retries = 3,
  37. .reconnect_interval_secs = 3,
  38. .usernames = {
  39. "Player 1",
  40. #if IZ_PLAYERS > 1
  41. "Player 2"
  42. #endif
  43. },
  44. },
  45. .binding = {
  46. .interrupted = false,
  47. .context = NULL,
  48. .connection = NULL,
  49. .user_data = NULL,
  50. },
  51. .params = {
  52. .port = 42069,
  53. .path = "/",
  54. .host = "localhost",
  55. },
  56. .callback = NULL,
  57. .action = {},
  58. .retries = 3,
  59. .status = IZ_NET_CLIENT_STATUS_PRISTINE,
  60. };
  61. IZ_ProcedureResult IZ_NetClientInitialize(IZ_NetClientState*, void*, void*, const char *, u8, const char *[]);
  62. void IZ_NetClientConnect(IZ_NetClientState*, IZ_WSClientInitializeParams);
  63. void IZ_NetClientDisconnect(IZ_NetClientState*);
  64. IZ_ProcedureResult IZ_NetClientSaveConfig(IZ_NetClientState*, const char*);
  65. void IZ_NetClientSendBinaryMessage(IZ_NetClientState*, void*, size_t);
  66. void IZ_NetClientSendTextMessage(IZ_NetClientState*, char*, size_t);
  67. #endif