aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/love
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-14 09:02:51 +1000
committerDavid Walter Seikel2014-05-14 09:02:51 +1000
commit8dc65d54d2c422690852b8bc7d0b7d35ca4582bc (patch)
tree7cd389f3139cb129f45003e88a172c6804d031ec /src/love
parentPurkle gets an append command, and use it from extantz to show llSay() and fr... (diff)
downloadSledjHamr-8dc65d54d2c422690852b8bc7d0b7d35ca4582bc.zip
SledjHamr-8dc65d54d2c422690852b8bc7d0b7d35ca4582bc.tar.gz
SledjHamr-8dc65d54d2c422690852b8bc7d0b7d35ca4582bc.tar.bz2
SledjHamr-8dc65d54d2c422690852b8bc7d0b7d35ca4582bc.tar.xz
Starting up and closing down the servers gets some love. Needs more love.
Diffstat (limited to 'src/love')
-rw-r--r--src/love/love.c95
1 files changed, 35 insertions, 60 deletions
diff --git a/src/love/love.c b/src/love/love.c
index 4d78a8c..e30c292 100644
--- a/src/love/love.c
+++ b/src/love/love.c
@@ -59,7 +59,7 @@ static int scriptCount = 0;
59static int compiledCount = 0; 59static int compiledCount = 0;
60static float compileTime = 0.0; 60static float compileTime = 0.0;
61static struct timeval startTime; 61static struct timeval startTime;
62static int timedEvent = 0; 62//static int timedEvent = 0;
63static char *ownerKey = "12345678-1234-4321-abcd-0123456789ab"; 63static char *ownerKey = "12345678-1234-4321-abcd-0123456789ab";
64static char *ownerName = "onefang rejected"; 64static char *ownerName = "onefang rejected";
65 65
@@ -176,58 +176,14 @@ static void dirList_compile(const char *name, const char *path, void *data)
176 176
177static Eina_Bool _timer_cb(void *data) 177static Eina_Bool _timer_cb(void *data)
178{ 178{
179 gameGlobals *ourGlobals = data; 179// gameGlobals *ourGlobals = data;
180 Eina_Iterator *scripts; 180 char buf[PATH_MAX];
181 script *me;
182 boolean exit = FALSE;
183 char buf[PATH_MAX];
184
185 if (5 == timedEvent)
186 {
187 gettimeofday(&startTime, NULL);
188 snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR);
189 eina_file_dir_list(buf, EINA_TRUE, dirList_compile, ourGlobals);
190 }
191
192 if (5 >= timedEvent)
193 {
194 timedEvent++;
195 return ECORE_CALLBACK_RENEW;
196 }
197 181
198 scripts = eina_hash_iterator_data_new(ourGlobals->scripts); 182 gettimeofday(&startTime, NULL);
199 while(eina_iterator_next(scripts, (void **) &me)) 183 snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR);
200 { 184 eina_file_dir_list(buf, EINA_TRUE, dirList_compile, data);
201 switch (timedEvent)
202 {
203 case 10 :
204 {
205 sendForth(ourGlobals->serverLuaSL, me->SID, "events.detectedKeys({\"%s\"})", ownerKey);
206 sendForth(ourGlobals->serverLuaSL, me->SID, "events.detectedNames({\"%s\"})", ownerName);
207 sendForth(ourGlobals->serverLuaSL, me->SID, "events.touch_start(1)");
208 break;
209 }
210 case 15 :
211 {
212 sendForth(ourGlobals->serverLuaSL, me->SID, "quit()");
213 break;
214 }
215 case 20 :
216 {
217 exit = TRUE;
218 break;
219 }
220 }
221 }
222 timedEvent++;
223 185
224 if (exit) 186 return ECORE_CALLBACK_CANCEL;
225 {
226 sendForth(ourGlobals->serverLuaSL, ownerKey, "exit()");
227 ecore_main_loop_quit();
228 return ECORE_CALLBACK_CANCEL;
229 }
230 return ECORE_CALLBACK_RENEW;
231} 187}
232 188
233static Eina_Bool _addLuaSL(void *data, int type, Ecore_Con_Event_Server_Add *ev) 189static Eina_Bool _addLuaSL(void *data, int type, Ecore_Con_Event_Server_Add *ev)
@@ -235,8 +191,8 @@ static Eina_Bool _addLuaSL(void *data, int type, Ecore_Con_Event_Server_Add *ev)
235 gameGlobals *ourGlobals = data; 191 gameGlobals *ourGlobals = data;
236 192
237 ourGlobals->serverLuaSL = ev->server; 193 ourGlobals->serverLuaSL = ev->server;
238 // Wait a while, then start sending events for testing. 194 // Wait a while before compiling and running scripts.
239 ecore_timer_add(0.5, _timer_cb, ourGlobals); 195 ecore_timer_add(3.0, _timer_cb, ourGlobals);
240 return ECORE_CALLBACK_RENEW; 196 return ECORE_CALLBACK_RENEW;
241} 197}
242 198
@@ -397,8 +353,6 @@ static Eina_Bool _delLuaSL(void *data, int type, Ecore_Con_Event_Server_Del *ev)
397 353
398 if (ev->server) 354 if (ev->server)
399 { 355 {
400 ourGlobals->serverLuaSL = NULL;
401 ecore_con_server_del(ev->server);
402 if (!ourGlobals->ui) 356 if (!ourGlobals->ui)
403 ecore_main_loop_quit(); 357 ecore_main_loop_quit();
404 } 358 }
@@ -507,13 +461,27 @@ static Eina_Bool _dataClient(void *data, int type, Ecore_Con_Event_Client_Data *
507 461
508static Eina_Bool _delClient(void *data, int type, Ecore_Con_Event_Client_Del *ev) 462static Eina_Bool _delClient(void *data, int type, Ecore_Con_Event_Client_Del *ev)
509{ 463{
510// gameGlobals *ourGlobals = data; 464 gameGlobals *ourGlobals = data;
511 465
512 if (ev->client) 466 if (ev->client)
513 { 467 {
514 PD("No more clients, exiting."); 468 Eina_List const *clients;
515 ecore_con_client_del(ev->client); 469 ecore_con_client_del(ev->client);
516 ecore_main_loop_quit(); 470
471 // This is only really for testing, normally it just runs 24/7, or until told to.
472 clients = ecore_con_server_clients_get(ourGlobals->server);
473 if (0 == eina_list_count(clients))
474 {
475 PD("No more clients, exiting.");
476 sendForth(ourGlobals->serverLuaSL, ownerKey, "exit()");
477 ecore_main_loop_quit();
478 }
479 else
480 {
481 PD("Some %d more clients, exiting anyway.", eina_list_count(clients));
482 sendForth(ourGlobals->serverLuaSL, ownerKey, "exit()");
483 ecore_main_loop_quit();
484 }
517 } 485 }
518 return ECORE_CALLBACK_RENEW; 486 return ECORE_CALLBACK_RENEW;
519} 487}
@@ -527,6 +495,9 @@ int main(int argc, char **argv)
527 int result = EXIT_FAILURE; 495 int result = EXIT_FAILURE;
528 char buf[PATH_MAX]; 496 char buf[PATH_MAX];
529 497
498// TODO - Just a temporary kill command until I can fix the LuaSL hanging on exit bug.
499system("killall -KILL LuaSL");
500sleep(2);
530 sprintf(buf, "%s/LuaSL &", PACKAGE_BIN_DIR); 501 sprintf(buf, "%s/LuaSL &", PACKAGE_BIN_DIR);
531 system(buf); 502 system(buf);
532 sleep(1); 503 sleep(1);
@@ -558,8 +529,6 @@ int main(int argc, char **argv)
558 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _delClient, &ourGlobals); 529 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _delClient, &ourGlobals);
559 ecore_con_server_timeout_set(ourGlobals.server, 0); 530 ecore_con_server_timeout_set(ourGlobals.server, 0);
560 ecore_con_server_client_limit_set(ourGlobals.server, -1, 0); 531 ecore_con_server_client_limit_set(ourGlobals.server, -1, 0);
561 ecore_con_server_timeout_set(ourGlobals.server, 10);
562 ecore_con_server_client_limit_set(ourGlobals.server, 3, 0);
563 clientStream = eina_strbuf_new(); 532 clientStream = eina_strbuf_new();
564 533
565 534
@@ -675,6 +644,11 @@ int main(int argc, char **argv)
675 } 644 }
676 645
677 ecore_main_loop_begin(); 646 ecore_main_loop_begin();
647 PD("Fell out of the main loop");
648
649 ecore_con_server_del(ourGlobals.server);
650 ecore_con_server_del(ourGlobals.serverLuaSL);
651
678 if (ourGlobals.ui) 652 if (ourGlobals.ui)
679 { 653 {
680 ecore_animator_del(ani); 654 ecore_animator_del(ani);
@@ -706,5 +680,6 @@ int main(int argc, char **argv)
706 else 680 else
707 fprintf(stderr, "Failed to init eina!"); 681 fprintf(stderr, "Failed to init eina!");
708 682
683 PD("Falling out of main()");
709 return result; 684 return result;
710} 685}