summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Messenger.c70
1 files changed, 17 insertions, 53 deletions
diff --git a/core/Messenger.c b/core/Messenger.c
index 58993a08..eb151a6a 100644
--- a/core/Messenger.c
+++ b/core/Messenger.c
@@ -482,9 +482,20 @@ int write_cryptpacket_id(Messenger *m, int friendnumber, uint8_t packet_id, uint
482 return write_cryptpacket(m->friendlist[friendnumber].crypt_connection_id, packet, length + 1); 482 return write_cryptpacket(m->friendlist[friendnumber].crypt_connection_id, packet, length + 1);
483} 483}
484 484
485<<<<<<< HEAD 485
486======= 486/*Interval in seconds between LAN discovery packet sending*/
487#define LAN_DISCOVERY_INTERVAL 60
488
487#define PORT 33445 489#define PORT 33445
490
491/*Send a LAN discovery packet every LAN_DISCOVERY_INTERVAL seconds*/
492int LANdiscovery(timer* t, void* arg)
493{
494 send_LANdiscovery(htons(PORT));
495 timer_start(t, LAN_DISCOVERY_INTERVAL);
496 return 0;
497}
498
488/* run this at startup */ 499/* run this at startup */
489Messenger * initMessenger(void) 500Messenger * initMessenger(void)
490{ 501{
@@ -506,6 +517,8 @@ Messenger * initMessenger(void)
506 friendreq_init(); 517 friendreq_init();
507 LANdiscovery_init(); 518 LANdiscovery_init();
508 519
520 timer_single(&LANdiscovery, 0, LAN_DISCOVERY_INTERVAL);
521
509 return m; 522 return m;
510} 523}
511 524
@@ -515,7 +528,6 @@ void cleanupMessenger(Messenger *m){
515 free(m); 528 free(m);
516} 529}
517 530
518>>>>>>> upstream/master
519//TODO: make this function not suck. 531//TODO: make this function not suck.
520void doFriends(Messenger *m) 532void doFriends(Messenger *m)
521{ 533{
@@ -665,67 +677,19 @@ void doInbound(Messenger *m)
665 } 677 }
666} 678}
667 679
668#define PORT 33445
669
670/*Interval in seconds between LAN discovery packet sending*/
671#define LAN_DISCOVERY_INTERVAL 60
672
673/*Send a LAN discovery packet every LAN_DISCOVERY_INTERVAL seconds*/
674<<<<<<< HEAD
675static int LANdiscovery_timercallback(timer* t, void* ignore)
676=======
677void LANdiscovery(Messenger *m)
678>>>>>>> upstream/master
679{
680 send_LANdiscovery(htons(PORT));
681 timer_start(t, LAN_DISCOVERY_INTERVAL);
682 return 0;
683}
684
685/* run this at startup */
686int initMessenger(void)
687{
688 timer_init();
689 new_keys();
690 m_set_statusmessage((uint8_t*)"Online", sizeof("Online"));
691 initNetCrypto();
692 IP ip;
693 ip.i = 0;
694
695 if(init_networking(ip,PORT) == -1)
696 return -1;
697
698 DHT_init();
699 LosslessUDP_init();
700 friendreq_init();
701 LANdiscovery_init();
702
703 timer_single(&LANdiscovery_timercallback, 0, LAN_DISCOVERY_INTERVAL);
704
705 return 0;
706}
707 680
708/* the main loop that needs to be run at least 200 times per second. */ 681/* the main loop that needs to be run at least 200 times per second. */
709void doMessenger(Messenger *m) 682void doMessenger(Messenger *m)
710{ 683{
711 networking_poll(); 684 networking_poll();
712<<<<<<< HEAD
713 timer_poll();
714
715 doDHT();
716 doLossless_UDP();
717 doNetCrypto();
718 doInbound();
719 doFriends();
720=======
721 685
722 doDHT(); 686 doDHT();
723 doLossless_UDP(); 687 doLossless_UDP();
724 doNetCrypto(); 688 doNetCrypto();
725 doInbound(m); 689 doInbound(m);
726 doFriends(m); 690 doFriends(m);
727 LANdiscovery(m); 691
728>>>>>>> upstream/master 692 timer_poll();
729} 693}
730 694
731/* returns the size of the messenger data (for saving) */ 695/* returns the size of the messenger data (for saving) */