diff options
author | irungentoo <irungentoo@gmail.com> | 2014-05-13 18:09:38 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-05-13 18:09:38 -0400 |
commit | 6b1578af3dcdd31e8fd967d1dd83a336990402c1 (patch) | |
tree | a15446fdfee9a1f20da81822cc372d9a94bfef4b /toxcore/TCP_client.h | |
parent | a05ab89dbfa0ff3fe2f926dbc583e2c2964e9fa2 (diff) |
TCP_client callbacks now have a per connection number that can be set.
Diffstat (limited to 'toxcore/TCP_client.h')
-rw-r--r-- | toxcore/TCP_client.h | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/toxcore/TCP_client.h b/toxcore/TCP_client.h index c2daaf9c..64678790 100644 --- a/toxcore/TCP_client.h +++ b/toxcore/TCP_client.h | |||
@@ -59,12 +59,13 @@ typedef struct { | |||
59 | struct { | 59 | struct { |
60 | uint8_t status; /* 0 if not used, 1 if other is offline, 2 if other is online. */ | 60 | uint8_t status; /* 0 if not used, 1 if other is offline, 2 if other is online. */ |
61 | uint8_t public_key[crypto_box_PUBLICKEYBYTES]; | 61 | uint8_t public_key[crypto_box_PUBLICKEYBYTES]; |
62 | uint32_t number; | ||
62 | } connections[NUM_CLIENT_CONNECTIONS]; | 63 | } connections[NUM_CLIENT_CONNECTIONS]; |
63 | int (*response_callback)(void *object, uint8_t connection_id, uint8_t *public_key); | 64 | int (*response_callback)(void *object, uint8_t connection_id, uint8_t *public_key); |
64 | void *response_callback_object; | 65 | void *response_callback_object; |
65 | int (*status_callback)(void *object, uint8_t connection_id, uint8_t status); | 66 | int (*status_callback)(void *object, uint32_t number, uint8_t connection_id, uint8_t status); |
66 | void *status_callback_object; | 67 | void *status_callback_object; |
67 | int (*data_callback)(void *object, uint8_t connection_id, uint8_t *data, uint16_t length); | 68 | int (*data_callback)(void *object, uint32_t number, uint8_t connection_id, uint8_t *data, uint16_t length); |
68 | void *data_callback_object; | 69 | void *data_callback_object; |
69 | 70 | ||
70 | int (*onion_callback)(void *object, uint8_t *data, uint16_t length); | 71 | int (*onion_callback)(void *object, uint8_t *data, uint16_t length); |
@@ -99,16 +100,24 @@ void onion_response_handler(TCP_Client_Connection *con, int (*onion_callback)(vo | |||
99 | int send_routing_request(TCP_Client_Connection *con, uint8_t *public_key); | 100 | int send_routing_request(TCP_Client_Connection *con, uint8_t *public_key); |
100 | void routing_response_handler(TCP_Client_Connection *con, int (*response_callback)(void *object, uint8_t connection_id, | 101 | void routing_response_handler(TCP_Client_Connection *con, int (*response_callback)(void *object, uint8_t connection_id, |
101 | uint8_t *public_key), void *object); | 102 | uint8_t *public_key), void *object); |
102 | void routing_status_handler(TCP_Client_Connection *con, int (*status_callback)(void *object, uint8_t connection_id, | 103 | void routing_status_handler(TCP_Client_Connection *con, int (*status_callback)(void *object, uint32_t number, |
103 | uint8_t status), void *object); | 104 | uint8_t connection_id, uint8_t status), void *object); |
104 | 105 | ||
106 | /* Set the number that will be used as an argument in the callbacks related to con_id. | ||
107 | * | ||
108 | * When not set by this function, the number is ~0. | ||
109 | * | ||
110 | * return 0 on success. | ||
111 | * return -1 on failure. | ||
112 | */ | ||
113 | int set_tcp_connection_number(TCP_Client_Connection *con, uint8_t con_id, uint32_t number); | ||
105 | 114 | ||
106 | /* return 1 on success. | 115 | /* return 1 on success. |
107 | * return 0 if could not send packet. | 116 | * return 0 if could not send packet. |
108 | * return -1 on failure. | 117 | * return -1 on failure. |
109 | */ | 118 | */ |
110 | int send_data(TCP_Client_Connection *con, uint8_t con_id, uint8_t *data, uint16_t length); | 119 | int send_data(TCP_Client_Connection *con, uint8_t con_id, uint8_t *data, uint16_t length); |
111 | void routing_data_handler(TCP_Client_Connection *con, int (*data_callback)(void *object, uint8_t connection_id, | 120 | void routing_data_handler(TCP_Client_Connection *con, int (*data_callback)(void *object, uint32_t number, |
112 | uint8_t *data, uint16_t length), void *object); | 121 | uint8_t connection_id, uint8_t *data, uint16_t length), void *object); |
113 | 122 | ||
114 | #endif | 123 | #endif |