diff options
author | Laurent Ghigonis <laurent@p1sec.com> | 2012-11-29 21:50:05 +0100 |
---|---|---|
committer | Laurent Ghigonis <laurent@p1sec.com> | 2012-11-29 21:50:05 +0100 |
commit | a381958b0d9477c8cc3412cb7d6eda0fba175b03 (patch) | |
tree | 387c2f5949b21f909df8c67abad8da58e2aa9f4a /libglouglou/libglouglou.h | |
parent | correctly gg_server_stop() the 2 servers on exit. (diff) | |
download | glouglou-a381958b0d9477c8cc3412cb7d6eda0fba175b03.tar.xz glouglou-a381958b0d9477c8cc3412cb7d6eda0fba175b03.zip |
many improvements, mainly on gg_client
* when client or server disconnects, correctly inform the other party
* add a reconnect mechanism for gg_client() based on timers
* clean function headers
* improve *_send() code
* client now ignores packets from someone else than it's server
Diffstat (limited to 'libglouglou/libglouglou.h')
-rw-r--r-- | libglouglou/libglouglou.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libglouglou/libglouglou.h b/libglouglou/libglouglou.h index 04ee779..17be3f7 100644 --- a/libglouglou/libglouglou.h +++ b/libglouglou/libglouglou.h @@ -91,11 +91,13 @@ struct gg_packet { struct gg_user { LIST_ENTRY(gg_user) entry; int id; + int sock; struct sockaddr_in addr; char *buf[16384]; }; struct gg_server { + struct event_base *ev_base; const char *ip; int port; struct sockaddr_in addr; @@ -108,15 +110,20 @@ struct gg_server { int user_id_count; }; +enum client_status { + GG_CLIENT_STATUS_CONNECTING = 0, + GG_CLIENT_STATUS_CONNECTED = 1 +}; + struct gg_client { + struct event_base *ev_base; const char *ip; int port; struct sockaddr_in addr; struct event *ev; + struct event *ev_timer; int sock; - int status; -#define GG_CLIENT_STATUS_DISCONNECTED 0 -#define GG_CLIENT_STATUS_CONNECTED 1 + enum client_status status; int (*handle_conn)(struct gg_client *); int (*handle_packet)(struct gg_client *, struct gg_packet *); void *usrdata; @@ -141,3 +148,4 @@ void *xmalloc(size_t); void *xcalloc(size_t, size_t); void fd_nonblock(int); void addrcpy(struct sockaddr_in *, struct sockaddr_in *); +int addrcmp(struct sockaddr_in *, struct sockaddr_in *); |