moonbridge

changeset 131:89fc89b22e28

Example application uses new "main" protocol; Handler for "main" gets table with "main" set to true
author jbe
date Wed Apr 15 00:59:52 2015 +0200 (2015-04-15)
parents ee98e12427a9
children 293e666a41e0
files example_application.lua moonbridge.c
line diff
     1.1 --- a/example_application.lua	Wed Apr 15 00:54:17 2015 +0200
     1.2 +++ b/example_application.lua	Wed Apr 15 00:59:52 2015 +0200
     1.3 @@ -147,9 +147,8 @@
     1.4  end
     1.5  
     1.6  listen{
     1.7 -  { proto = "interval", delay = 1 },
     1.8 -  connect = chat_server,
     1.9 -  max_fork = 1
    1.10 +  { proto = "main" },
    1.11 +  connect = chat_server
    1.12  }
    1.13  
    1.14  listen{
     2.1 --- a/moonbridge.c	Wed Apr 15 00:54:17 2015 +0200
     2.2 +++ b/moonbridge.c	Wed Apr 15 00:59:52 2015 +0200
     2.3 @@ -794,11 +794,16 @@
     2.4      lua_rawgetp(L, LUA_REGISTRYINDEX, moonbr_luakey_connect_func(pool));
     2.5      if (fd < 0) {
     2.6        lua_newtable(L);
     2.7 -      lua_pushstring(L,
     2.8 -        listener->type_specific.interval.name ?
     2.9 -        listener->type_specific.interval.name : ""
    2.10 -      );
    2.11 -      lua_setfield(L, -2, "interval");
    2.12 +      if (listener->proto == MOONBR_PROTO_MAIN) {
    2.13 +        lua_pushboolean(L, 1);
    2.14 +        lua_setfield(L, -2, "main");
    2.15 +      } else if (listener->proto == MOONBR_PROTO_INTERVAL) {
    2.16 +        lua_pushstring(L,
    2.17 +          listener->type_specific.interval.name ?
    2.18 +          listener->type_specific.interval.name : ""
    2.19 +        );
    2.20 +        lua_setfield(L, -2, "interval");
    2.21 +      }
    2.22      } else {
    2.23        lua_pushvalue(L, -2);
    2.24      }

Impressum / About Us