aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--LuaSL/src/LuaSL_main.c15
-rw-r--r--LuaSL/src/LuaSL_test.c40
2 files changed, 52 insertions, 3 deletions
diff --git a/LuaSL/src/LuaSL_main.c b/LuaSL/src/LuaSL_main.c
index 0aaf3c5..e209023 100644
--- a/LuaSL/src/LuaSL_main.c
+++ b/LuaSL/src/LuaSL_main.c
@@ -5,6 +5,14 @@
5static int CPUs = 4; 5static int CPUs = 4;
6static Eina_Strbuf *clientStream; 6static Eina_Strbuf *clientStream;
7 7
8static void sendBack(gameGlobals *game, Ecore_Con_Client *client, const char *SID, const char *message)
9{
10 char buf[PATH_MAX];
11
12 sprintf(buf, "%s.%s\n", SID, message);
13 ecore_con_client_send(client, buf, strlen(buf));
14 ecore_con_client_flush(client);
15}
8 16
9static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Add *ev) 17static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Add *ev)
10{ 18{
@@ -35,10 +43,11 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D
35 command = ext + 1; 43 command = ext + 1;
36 if (0 == strcmp(command, "compile()")) 44 if (0 == strcmp(command, "compile()"))
37 { 45 {
46 PD("Compiling %s.", SID);
38 if (compileLSL(game, SID, FALSE)) 47 if (compileLSL(game, SID, FALSE))
39 PD("The compile of %s worked.", SID); 48 sendBack(game, ev->client, SID, "compiled(true)");
40 else 49 else
41 PE("The compile of %s failed!", SID); 50 sendBack(game, ev->client, SID, "compiled(false)");
42 } 51 }
43 else if (0 == strcmp(command, "start()")) 52 else if (0 == strcmp(command, "start()"))
44 { 53 {
@@ -57,7 +66,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D
57 snprintf(temp, sizeof(temp), "%s.events", SID); 66 snprintf(temp, sizeof(temp), "%s.events", SID);
58 status = sendToChannel(temp, command, NULL, NULL); 67 status = sendToChannel(temp, command, NULL, NULL);
59 if (status) 68 if (status)
60 PE("Error sending command %s to script %s : %s", command, temp, status); 69 PE("Error sending command %s to script %s : %s", command, SID, status);
61 } 70 }
62 } 71 }
63 72
diff --git a/LuaSL/src/LuaSL_test.c b/LuaSL/src/LuaSL_test.c
index f49a9f5..8faa041 100644
--- a/LuaSL/src/LuaSL_test.c
+++ b/LuaSL/src/LuaSL_test.c
@@ -1,6 +1,7 @@
1 1
2#include "LuaSL.h" 2#include "LuaSL.h"
3 3
4static Eina_Strbuf *clientStream;
4 5
5static const char *names[] = 6static const char *names[] =
6{ 7{
@@ -128,6 +129,44 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_D
128{ 129{
129 gameGlobals *game = data; 130 gameGlobals *game = data;
130 131
132 char buf[PATH_MAX];
133 char SID[PATH_MAX];
134 const char *command;
135 char *ext;
136
137 eina_strbuf_append_length(clientStream, ev->data, ev->size);
138 command = eina_strbuf_string_get(clientStream);
139 while ((ext = index(command, '\n')))
140 {
141 int length = ext - command;
142
143 strncpy(SID, command, length + 1);
144 SID[length] = '\0';
145 eina_strbuf_remove(clientStream, 0, length + 1);
146 ext = rindex(SID, '.');
147 if (ext)
148 {
149 ext[0] = '\0';
150 command = ext + 1;
151 if (0 == strcmp(command, "compiled(false)"))
152 PE("The compile of %s failed!", SID);
153 else if (0 == strcmp(command, "compiled(true)"))
154 {
155 PD("The compile of %s worked, running it now.", SID);
156 snprintf(buf, sizeof(buf), "%s.lua.out.start()\n", SID);
157 ecore_con_server_send(game->server, buf, strlen(buf));
158 ecore_con_server_flush(game->server);
159 }
160 else
161 {
162 PI("Command %s from script %s", command, SID);
163 }
164 }
165
166 // Get the next blob to check it.
167 command = eina_strbuf_string_get(clientStream);
168 }
169
131 return ECORE_CALLBACK_RENEW; 170 return ECORE_CALLBACK_RENEW;
132} 171}
133 172
@@ -167,6 +206,7 @@ int main(int argc, char **argv)
167 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb) _add, &game); 206 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb) _add, &game);
168 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb) _data, &game); 207 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb) _data, &game);
169 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, (Ecore_Event_Handler_Cb) _del, &game); 208 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, (Ecore_Event_Handler_Cb) _del, &game);
209 clientStream = eina_strbuf_new();
170 210
171 if (ecore_evas_init()) 211 if (ecore_evas_init())
172 { 212 {