aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/love/love.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/love/love.c b/src/love/love.c
index 2d5f2a4..c33fe2c 100644
--- a/src/love/love.c
+++ b/src/love/love.c
@@ -479,14 +479,32 @@ static Eina_Bool _dataLuaSL(void *data, int type, Ecore_Con_Event_Server_Data *e
479 return ECORE_CALLBACK_RENEW; 479 return ECORE_CALLBACK_RENEW;
480} 480}
481 481
482// Forward declare a circular reference.
483static Eina_Bool _delLuaSL(void *data, int type, Ecore_Con_Event_Server_Del *ev);
484
485static Eina_Bool _serverDelTimer(void *data)
486{
487 gameGlobals *ourGlobals = data;
488
489 ourGlobals->serverLuaSL = reachOut("127.0.0.1", 8211, ourGlobals, (Ecore_Event_Handler_Cb) _addLuaSL, (Ecore_Event_Handler_Cb) _dataLuaSL, (Ecore_Event_Handler_Cb) _delLuaSL);
490 return ECORE_CALLBACK_CANCEL;
491}
492
482static Eina_Bool _delLuaSL(void *data, int type, Ecore_Con_Event_Server_Del *ev) 493static Eina_Bool _delLuaSL(void *data, int type, Ecore_Con_Event_Server_Del *ev)
483{ 494{
484 gameGlobals *ourGlobals = data; 495 gameGlobals *ourGlobals = data;
485 496
486 if (ev->server) 497 if (ev->server)
487 { 498 {
499 ecore_con_server_del(ev->server);
500 ourGlobals->serverLuaSL = NULL;
488 if (!ourGlobals->ui) 501 if (!ourGlobals->ui)
489 ecore_main_loop_quit(); 502 ecore_main_loop_quit();
503 else
504 {
505 PW("Server dropped out, trying to reconnect.");
506 ecore_timer_add(1.0, _serverDelTimer, ourGlobals);
507 }
490 } 508 }
491 509
492 return ECORE_CALLBACK_RENEW; 510 return ECORE_CALLBACK_RENEW;
@@ -597,12 +615,8 @@ int main(int argc, char **argv)
597 int result = EXIT_FAILURE; 615 int result = EXIT_FAILURE;
598 char buf[PATH_MAX]; 616 char buf[PATH_MAX];
599 617
600// TODO - Just a temporary kill command until I can fix the LuaSL hanging on exit bug.
601system("killall -KILL LuaSL");
602sleep(2);
603 sprintf(buf, "%s/LuaSL &", PACKAGE_BIN_DIR); 618 sprintf(buf, "%s/LuaSL &", PACKAGE_BIN_DIR);
604 system(buf); 619 system(buf);
605 sleep(1);
606 620
607 memset(&ourGlobals, 0, sizeof(gameGlobals)); 621 memset(&ourGlobals, 0, sizeof(gameGlobals));
608 ourGlobals.address = "127.0.0.1"; 622 ourGlobals.address = "127.0.0.1";
@@ -615,23 +629,17 @@ sleep(2);
615 629
616 if (ecore_con_init()) 630 if (ecore_con_init())
617 { 631 {
618 if ((ourGlobals.serverLuaSL = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals))) 632 LuaSLStream = eina_strbuf_new();
619 { 633 clientStream = eina_strbuf_new();
620 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb) _addLuaSL, &ourGlobals); 634 reachOut("127.0.0.1", 8211, &ourGlobals, (Ecore_Event_Handler_Cb) _addLuaSL, (Ecore_Event_Handler_Cb) _dataLuaSL, (Ecore_Event_Handler_Cb) _delLuaSL);
621 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb) _dataLuaSL, &ourGlobals);
622 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, (Ecore_Event_Handler_Cb) _delLuaSL, &ourGlobals);
623 LuaSLStream = eina_strbuf_new();
624 635
625 if ((ourGlobals.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port + 1, &ourGlobals))) 636 if ((ourGlobals.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port + 1, &ourGlobals)))
626 { 637 {
627// int i;
628
629 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb) _addClient, &ourGlobals); 638 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb) _addClient, &ourGlobals);
630 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _dataClient, &ourGlobals); 639 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _dataClient, &ourGlobals);
631 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _delClient, &ourGlobals); 640 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _delClient, &ourGlobals);
632 ecore_con_server_timeout_set(ourGlobals.server, 0); 641 ecore_con_server_timeout_set(ourGlobals.server, 0);
633 ecore_con_server_client_limit_set(ourGlobals.server, -1, 0); 642 ecore_con_server_client_limit_set(ourGlobals.server, -1, 0);
634 clientStream = eina_strbuf_new();
635 643
636 644
637 if (ecore_evas_init()) 645 if (ecore_evas_init())
@@ -771,9 +779,6 @@ sleep(2);
771 else 779 else
772 PC("Failed to add server!"); 780 PC("Failed to add server!");
773 781
774 }
775 else
776 PC("Failed to connect to server!");
777 ecore_con_shutdown(); 782 ecore_con_shutdown();
778 } 783 }
779 else 784 else