From 2a5e8c3534d070de3bf142af47e29fb835498ad9 Mon Sep 17 00:00:00 2001 From: Laurent Ghigonis Date: Thu, 29 Nov 2012 10:08:56 +0100 Subject: add a way to pass userdata to server and client callbacks --- libglouglou/libglouglou.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libglouglou/libglouglou.c') diff --git a/libglouglou/libglouglou.c b/libglouglou/libglouglou.c index efbd256..a3eb271 100644 --- a/libglouglou/libglouglou.c +++ b/libglouglou/libglouglou.c @@ -29,7 +29,8 @@ void cb_cli_receive(evutil_socket_t, short, void *); struct gg_server * gg_server_start(struct event_base *ev_base, char *ip, int port, int (*handle_conn)(struct gg_server *, struct gg_user *), - int (*handle_packet)(struct gg_server *, struct gg_user *, struct gg_packet *)) + int (*handle_packet)(struct gg_server *, struct gg_user *, struct gg_packet *), + void *usrdata) { struct gg_server *srv; struct sockaddr_in sock_addr; @@ -42,6 +43,7 @@ gg_server_start(struct event_base *ev_base, char *ip, int port, srv->port = port; srv->handle_conn = handle_conn; srv->handle_packet = handle_packet; + srv->usrdata = usrdata; s = socket(AF_INET, SOCK_DGRAM, 0); if (s < 0) goto err; @@ -272,7 +274,8 @@ void cb_srv_receive(evutil_socket_t fd, short what, void *arg) struct gg_client * gg_client_connect(struct event_base *ev_base, char *ip, int port, int (*handle_conn)(struct gg_client *), - int (*handle_packet)(struct gg_client *, struct gg_packet *)) + int (*handle_packet)(struct gg_client *, struct gg_packet *), + void *usrdata) { struct gg_client *cli; struct sockaddr_in sock_addr; @@ -285,6 +288,7 @@ gg_client_connect(struct event_base *ev_base, char *ip, int port, cli->port = port; cli->handle_conn = handle_conn; cli->handle_packet = handle_packet; + cli->usrdata = usrdata; s = socket(AF_INET, SOCK_DGRAM, 0); if (s < 0) goto err; -- cgit v1.2.3-59-g8ed1b