summaryrefslogtreecommitdiff
path: root/protocols/Tox/tox/include/tox.h
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Tox/tox/include/tox.h')
-rw-r--r--protocols/Tox/tox/include/tox.h63
1 files changed, 55 insertions, 8 deletions
diff --git a/protocols/Tox/tox/include/tox.h b/protocols/Tox/tox/include/tox.h
index 5810c1289c..1f2510856c 100644
--- a/protocols/Tox/tox/include/tox.h
+++ b/protocols/Tox/tox/include/tox.h
@@ -153,12 +153,8 @@ int tox_friend_exists(const Tox *tox, int32_t friendnumber);
*
* You will want to retain the return value, it will be passed to your read_receipt callback
* if one is received.
- * m_sendmessage_withid will send a message with the id of your choosing,
- * however we can generate an id for you by calling plain m_sendmessage.
*/
uint32_t tox_send_message(Tox *tox, int32_t friendnumber, const uint8_t *message, uint32_t length);
-uint32_t tox_send_message_withid(Tox *tox, int32_t friendnumber, uint32_t theid, const uint8_t *message,
- uint32_t length);
/* Send an action to an online friend.
*
@@ -171,16 +167,13 @@ uint32_t tox_send_message_withid(Tox *tox, int32_t friendnumber, uint32_t theid,
*
* You will want to retain the return value, it will be passed to your read_receipt callback
* if one is received.
- * m_sendaction_withid will send an action message with the id of your choosing,
- * however we can generate an id for you by calling plain m_sendaction.
*/
uint32_t tox_send_action(Tox *tox, int32_t friendnumber, const uint8_t *action, uint32_t length);
-uint32_t tox_send_action_withid(Tox *tox, int32_t friendnumber, uint32_t theid, const uint8_t *action, uint32_t length);
/* Set our nickname.
* name must be a string of maximum MAX_NAME_LENGTH length.
* length must be at least 1 byte.
- * length is the length of name with the NULL terminator.
+ * length is the length of name.
*
* return 0 if success.
* return -1 if failure.
@@ -361,6 +354,53 @@ void tox_set_nospam(Tox *tox, uint32_t nospam);
if the pointer is NULL, no data will be copied to it.*/
void tox_get_keys(Tox *tox, uint8_t *public_key, uint8_t *secret_key);
+/* Maximum size of custom packets. */
+#define TOX_MAX_CUSTOM_PACKET_SIZE 1373
+
+/* Set handlers for custom lossy packets.
+ * Set the function to be called when friend sends us a lossy packet starting with byte.
+ * byte must be in the 200-254 range.
+ *
+ * NOTE: lossy packets behave like UDP packets meaning they might never reach the other side
+ * or might arrive more than once (if someone is messing with the connection) or might arrive
+ * in the wrong order.
+ *
+ * Unless latency is an issue, it is recommended that you use lossless packets instead.
+ *
+ * return -1 on failure.
+ * return 0 on success.
+ */
+int tox_lossy_packet_registerhandler(Tox *tox, int32_t friendnumber, uint8_t byte,
+ int (*packet_handler_callback)(void *object, const uint8_t *data, uint32_t len), void *object);
+
+/* Function to send custom lossy packets.
+ * First byte of data must be in the range: 200-254.
+ *
+ * return -1 on failure.
+ * return 0 on success.
+ */
+int tox_send_lossy_packet(const Tox *tox, int32_t friendnumber, const uint8_t *data, uint32_t length);
+
+/* Set handlers for custom lossless packets.
+ * Set the function to be called when friend sends us a lossless packet starting with byte.
+ * byte must be in the 160-191 range.
+ *
+ * Lossless packets behave kind of like TCP (reliability, arrive in order.) but with packets instead of a stream.
+ *
+ * return -1 on failure.
+ * return 0 on success.
+ */
+int tox_lossless_packet_registerhandler(Tox *tox, int32_t friendnumber, uint8_t byte,
+ int (*packet_handler_callback)(void *object, const uint8_t *data, uint32_t len), void *object);
+
+/* Function to send custom lossless packets.
+ * First byte of data must be in the range: 160-191.
+ *
+ * return -1 on failure.
+ * return 0 on success.
+ */
+int tox_send_lossless_packet(const Tox *tox, int32_t friendnumber, const uint8_t *data, uint32_t length);
+
/**********GROUP CHAT FUNCTIONS: WARNING Group chats will be rewritten so this might change ************/
/* Set the callback for group invites.
@@ -608,6 +648,13 @@ uint64_t tox_file_data_remaining(const Tox *tox, int32_t friendnumber, uint8_t f
*/
int tox_bootstrap_from_address(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key);
+/* Like tox_bootstrap_from_address but for TCP relays only.
+ *
+ * return 0 on failure.
+ * return 1 on success.
+ */
+int tox_add_tcp_relay(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key);
+
/* return 0 if we are not connected to the DHT.
* return 1 if we are.
*/