示例#1
0
  //--------------------------------------------------------------------------------
  void BspProxyStubPool::bspSend(const int & taskPid, BspSend & bspSend){

    int initialStackSize = lua_gettop(clientSideState);

    lua_getglobal(clientSideState, getTaskId(taskPid).c_str());
    lua_pushstring(clientSideState, "bspSend");
    lua_gettable(clientSideState, -2);
    lua_getglobal(clientSideState, getTaskId(taskPid).c_str());
    lua_newtable(clientSideState);


    LuaUtils::setFieldOnTable(clientSideState, "nBytes", bspSend.nBytes(), -1);
    LuaUtils::setFieldOnTable(clientSideState, "tagSize", bspSend.tagSize(), -1);
    LuaUtils::setFieldOnTable(clientSideState, "superstep", bspSend.superstep(), -1);
    lua_pushstring(clientSideState, "payload");
    const char * payload = (char *) bspSend.payload();
    lua_pushlstring(clientSideState, payload, bspSend.nBytes());
    lua_settable(clientSideState, -3);
    lua_pushstring(clientSideState, "tag");
    const char * tag = (char *) bspSend.tag();
    lua_pushlstring(clientSideState, tag, bspSend.tagSize());
    lua_settable(clientSideState, -3);




    if (lua_pcall(clientSideState, 2, 0, 0) != 0){
      cerr << "[ERROR] BspProxyStubPool::bspSend->Lua error: "
           << lua_tostring(clientSideState, -1) << endl;
      lua_pop(clientSideState, 1);
    }

    lua_pop(clientSideState, 1);//removes proxy from stack
    assert(initialStackSize == lua_gettop(clientSideState));

  }