summaryrefslogtreecommitdiff
path: root/core/Messenger.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/Messenger.c')
-rw-r--r--core/Messenger.c43
1 files changed, 15 insertions, 28 deletions
diff --git a/core/Messenger.c b/core/Messenger.c
index 5f33886f..082b10d2 100644
--- a/core/Messenger.c
+++ b/core/Messenger.c
@@ -683,35 +683,22 @@ static void LANdiscovery(void)
683/* the main loop that needs to be run at least 200 times per second. */ 683/* the main loop that needs to be run at least 200 times per second. */
684void doMessenger(void) 684void doMessenger(void)
685{ 685{
686 IP_Port ip_port; 686 networking_poll();
687 uint8_t data[MAX_UDP_PACKET_SIZE];
688 uint32_t length;
689 while (receivepacket(&ip_port, data, &length) != -1) {
690#ifdef DEBUG
691 /* if(rand() % 3 != 1) //simulate packet loss */
692 /* { */
693 if (DHT_handlepacket(data, length, ip_port) && LosslessUDP_handlepacket(data, length, ip_port) &&
694 friendreq_handlepacket(data, length, ip_port) && LANdiscovery_handlepacket(data, length, ip_port))
695 /* if packet is discarded */
696 printf("Received unhandled packet with length: %u\n", length);
697 else
698 printf("Received handled packet with length: %u\n", length);
699 /* } */
700 printf("Status: %u %u %u\n",friendlist[0].status ,is_cryptoconnected(friendlist[0].crypt_connection_id), friendlist[0].crypt_connection_id);
701#else
702 DHT_handlepacket(data, length, ip_port);
703 LosslessUDP_handlepacket(data, length, ip_port);
704 friendreq_handlepacket(data, length, ip_port);
705 LANdiscovery_handlepacket(data, length, ip_port);
706#endif
707 687
708 } 688 doDHT();
709 doDHT(); 689 doLossless_UDP();
710 doLossless_UDP(); 690 doNetCrypto();
711 doNetCrypto(); 691 doInbound();
712 doInbound(); 692 doFriends();
713 doFriends(); 693 LANdiscovery();
714 LANdiscovery(); 694}
695
696void Messenger_init(void)
697{
698 DHT_init();
699 LosslessUDP_init();
700 friendreq_init();
701 LANdiscovery_init();
715} 702}
716 703
717/* returns the size of the messenger data (for saving) */ 704/* returns the size of the messenger data (for saving) */