From dcd11c8d2b399ce1309637bd756c680db0aec1af Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sat, 17 May 2014 10:54:52 +1000 Subject: Use the new server connector, and some related movements. --- src/purkle/purkle.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/purkle') diff --git a/src/purkle/purkle.c b/src/purkle/purkle.c index 6770ff4..9cafe01 100644 --- a/src/purkle/purkle.c +++ b/src/purkle/purkle.c @@ -1,4 +1,3 @@ -//#include "LumbrJack.h" #include "GuiLua.h" #include "Runnr.h" #include "SledjHamr.h" @@ -8,7 +7,6 @@ static const char *ourName = "purkle"; static int skang, _M; static Widget *entry, *history; static winFang *me; -static Ecore_Con_Server *server; static winFang *purkleAdd(winFang *parent, int w, int h, EPhysics_World *world) { @@ -60,7 +58,16 @@ static int say(lua_State *L) pull_lua(L, 1, "%channel $name $id $text", &channel, &name, &id, &text); if (id && text) { + GuiLua *gl; + Ecore_Con_Server *server = NULL; + snprintf(buf, sizeof(buf), "events.listen(%d, '%s', '%s', '%s')", channel, name, id, text); + // We do this rather than caching it, coz the server might change out from under us. + lua_getfield(L, LUA_REGISTRYINDEX, glName); + gl = lua_touserdata(L, -1); + lua_pop(L, 1); + if (gl) + server = gl->server; if (server) sendForth(server, id, buf); else @@ -97,7 +104,6 @@ int luaopen_purkle(lua_State *L) { parent = gl->parent; world = gl->world; - server = gl->server; } if (!me) me = purkleAdd(parent, 500, 420, world); -- cgit v1.1