aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/extantz/extantz.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/extantz/extantz.c')
-rw-r--r--src/extantz/extantz.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c
index 22244ba..8d533fd 100644
--- a/src/extantz/extantz.c
+++ b/src/extantz/extantz.c
@@ -7,8 +7,86 @@
7 7
8static int logDom; // Our logging domain. 8static int logDom; // Our logging domain.
9globals ourGlobals; 9globals ourGlobals;
10static Eina_Strbuf *serverStream;
10 11
11 12
13
14static Eina_Bool _add(void *data, int type, Ecore_Con_Event_Server_Add *ev)
15{
16 globals *ourGlobals = data;
17
18 ourGlobals->server = ev->server;
19 return ECORE_CALLBACK_RENEW;
20}
21
22static Eina_Bool _data(void *data, int type, Ecore_Con_Event_Server_Data *ev)
23{
24// globals *ourGlobals = data;
25// char buf[PATH_MAX];
26 char SID[PATH_MAX];
27 const char *command;
28 char *ext;
29
30 eina_strbuf_append_length(serverStream, ev->data, ev->size);
31 command = eina_strbuf_string_get(serverStream);
32 while ((ext = index(command, '\n')))
33 {
34 int length = ext - command;
35
36 strncpy(SID, command, length + 1);
37 SID[length] = '\0';
38 eina_strbuf_remove(serverStream, 0, length + 1);
39 ext = index(SID, '.');
40 if (ext)
41 {
42 ext[0] = '\0';
43 command = ext + 1;
44 if (0 == strncmp(command, "llOwnerSay(", 11))
45 {
46 PI("Saying to owner from %s - %s", SID, command);
47 }
48 else if (0 == strncmp(command, "llWhisper(", 10))
49 {
50 PI("Whispering from %s - %s", SID, command);
51 }
52 else if (0 == strncmp(command, "llSay(", 6))
53 {
54 PI("Saying from %s - %s", SID, command);
55 }
56 else if (0 == strncmp(command, "llShout(", 8))
57 {
58 PI("Shouting from %s - %s", SID, command);
59 }
60 else if (0 == strncmp(command, "llDialog(", 9))
61 {
62 PI("Dialog from %s - %s", SID, command);
63 }
64 else
65 {
66 PI("Some random command %s", command);
67 }
68 }
69
70 // Get the next blob to check it.
71 command = eina_strbuf_string_get(serverStream);
72 }
73
74 return ECORE_CALLBACK_RENEW;
75}
76
77static Eina_Bool _del(void *data, int type, Ecore_Con_Event_Server_Del *ev)
78{
79 globals *ourGlobals = data;
80
81 if (ev->server)
82 {
83 ourGlobals->server = NULL;
84 ecore_con_server_del(ev->server);
85 }
86
87 return ECORE_CALLBACK_RENEW;
88}
89
12static void gldata_init(GLData *gld) 90static void gldata_init(GLData *gld)
13{ 91{
14 gld->useIrr = USE_IRR; 92 gld->useIrr = USE_IRR;
@@ -556,8 +634,23 @@ EAPI_MAIN int elm_main(int argc, char **argv)
556 634
557 _on_resize(&ourGlobals, NULL, NULL, NULL); 635 _on_resize(&ourGlobals, NULL, NULL, NULL);
558 636
637 // Try to connect to the love server we started before.
638 ourGlobals.address = "127.0.0.1";
639 ourGlobals.port = 8211;
640 if ((ourGlobals.server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port + 1, &ourGlobals)))
641 {
642 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals);
643 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb) _data, &ourGlobals);
644 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, (Ecore_Event_Handler_Cb) _del, &ourGlobals);
645 serverStream = eina_strbuf_new();
646 }
647 else
648 PC("Failed to connect to server!");
649
559 elm_run(); 650 elm_run();
560 651
652 if (ourGlobals.server) ecore_con_server_del(ourGlobals.server);
653
561 ephysics_world_del(ourGlobals.world); 654 ephysics_world_del(ourGlobals.world);
562 ephysics_shutdown(); 655 ephysics_shutdown();
563 656