diff options
author | David Walter Seikel | 2014-05-18 13:27:05 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-18 13:27:05 +1000 |
commit | 5b3f4f59112aeb4c91806103c487ca3148b63486 (patch) | |
tree | 15f234b9ab9551b8129465a136430d16a4eff3b9 /src/extantz | |
parent | No need to say this is where the history is show now that it's actually being... (diff) | |
download | SledjHamr-5b3f4f59112aeb4c91806103c487ca3148b63486.zip SledjHamr-5b3f4f59112aeb4c91806103c487ca3148b63486.tar.gz SledjHamr-5b3f4f59112aeb4c91806103c487ca3148b63486.tar.bz2 SledjHamr-5b3f4f59112aeb4c91806103c487ca3148b63486.tar.xz |
Clean up the server startup and connection a bit.
Diffstat (limited to 'src/extantz')
-rw-r--r-- | src/extantz/extantz.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c index 74a0c58..ff418c0 100644 --- a/src/extantz/extantz.c +++ b/src/extantz/extantz.c | |||
@@ -19,7 +19,7 @@ static Eina_Bool _add(void *data, int type, Ecore_Con_Event_Server_Add *ev) | |||
19 | { | 19 | { |
20 | globals *ourGlobals = data; | 20 | globals *ourGlobals = data; |
21 | 21 | ||
22 | PI("Server connected."); | 22 | PI("Connected to love server."); |
23 | ourGlobals->server = ev->server; | 23 | ourGlobals->server = ev->server; |
24 | if (ourGlobals->LSLGuiMess) ourGlobals->LSLGuiMess->server = ourGlobals->server; | 24 | if (ourGlobals->LSLGuiMess) ourGlobals->LSLGuiMess->server = ourGlobals->server; |
25 | if (ourGlobals->purkle) ourGlobals->purkle->server = ourGlobals->server; | 25 | if (ourGlobals->purkle) ourGlobals->purkle->server = ourGlobals->server; |
@@ -104,32 +104,29 @@ static Eina_Bool _data(void *data, int type, Ecore_Con_Event_Server_Data *ev) | |||
104 | return ECORE_CALLBACK_RENEW; | 104 | return ECORE_CALLBACK_RENEW; |
105 | } | 105 | } |
106 | 106 | ||
107 | // Forward declare a circular reference. | ||
108 | static Eina_Bool _del(void *data, int type, Ecore_Con_Event_Server_Del *ev); | ||
109 | |||
110 | static Eina_Bool _serverDelTimer(void *data) | ||
111 | { | ||
112 | globals *ourGlobals = data; | ||
113 | |||
114 | ourGlobals->server = reachOut("127.0.0.1", 8211 + 1, ourGlobals, (Ecore_Event_Handler_Cb) _add, (Ecore_Event_Handler_Cb) _data, (Ecore_Event_Handler_Cb) _del); | ||
115 | return ECORE_CALLBACK_CANCEL; | ||
116 | } | ||
117 | |||
118 | static Eina_Bool _del(void *data, int type, Ecore_Con_Event_Server_Del *ev) | 107 | static Eina_Bool _del(void *data, int type, Ecore_Con_Event_Server_Del *ev) |
119 | { | 108 | { |
120 | globals *ourGlobals = data; | 109 | globals *ourGlobals = data; |
110 | static int count = 0; | ||
111 | |||
112 | ourGlobals->server = NULL; | ||
121 | 113 | ||
122 | if (ev->server) | 114 | // Let it fail a couple of times during startup, then try to start our own love server. |
115 | count++; | ||
116 | if (1 < count) | ||
123 | { | 117 | { |
124 | ecore_con_server_del(ev->server); | 118 | char buf[PATH_MAX]; |
125 | ourGlobals->server = NULL; | 119 | |
126 | if (ourGlobals->running) | 120 | PW("Failed to connect to a world server, starting our own."); |
127 | { | 121 | |
128 | PW("Server dropped out, trying to reconnect."); | 122 | // TODO - Should use Ecore_Exe for this sort of thing. |
129 | ecore_timer_add(1.0, _serverDelTimer, ourGlobals); | 123 | sprintf(buf, "%s/love &", elm_app_bin_dir_get()); |
130 | } | 124 | system(buf); |
125 | count = 0; | ||
131 | } | 126 | } |
132 | 127 | ||
128 | if (ourGlobals->running) | ||
129 | return ECORE_CALLBACK_RENEW; | ||
133 | return ECORE_CALLBACK_CANCEL; | 130 | return ECORE_CALLBACK_CANCEL; |
134 | } | 131 | } |
135 | 132 | ||
@@ -576,9 +573,6 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
576 | logDom = loggingStartup("extantz", logDom); | 573 | logDom = loggingStartup("extantz", logDom); |
577 | ourGlobals.running = 1; | 574 | ourGlobals.running = 1; |
578 | 575 | ||
579 | // TODO - Should use Ecore_Exe for this sort of thing. | ||
580 | sprintf(buf, "%s/love &", elm_app_bin_dir_get()); | ||
581 | system(buf); | ||
582 | 576 | ||
583 | // Don't do this, we need to clean up other stuff to, so set a clean up function below. | 577 | // Don't do this, we need to clean up other stuff to, so set a clean up function below. |
584 | //elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); | 578 | //elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); |