38 lines
1.2 KiB
Lua
38 lines
1.2 KiB
Lua
function plugin_ctx_new(sess, plug_env, sess_context)
|
|
print("now create new ctx example-2, plugin id ", plug_env.id)
|
|
local sessid = session.getid(sess)
|
|
sess_context.id = 200
|
|
print("session id is ", sessid)
|
|
session.setid(sess, 50000)
|
|
end
|
|
|
|
function plugin_ctx_free(sess, sess_context, plug_env)
|
|
print(sess_context.id)
|
|
print("now begin to free ctx context example-2")
|
|
end
|
|
|
|
function free_message()
|
|
print("free message")
|
|
end
|
|
|
|
function plugin_load(stellar, plug_env)
|
|
print("now begin to load plugin example-2")
|
|
plug_env.id = plugin_manage.register(stellar, plugin_ctx_new, plugin_ctx_free, plug_env)
|
|
topic_id = message.gettopicid(stellar, "TOPIC_SESSION_STAT")
|
|
print("get topic id is ", topic_id)
|
|
create_id = message.gettopicid(stellar, "TOPIC_LUA_SESSION_TEST")
|
|
if (create_id < 0)
|
|
then
|
|
print("no topic, create new one")
|
|
create_table = {}
|
|
create_id = message.createtopic(stellar, "TOPIC_LUA_SESSION_TEST", free_message, create_table)
|
|
print("create topic is ", create_id)
|
|
else
|
|
print("has created, id is ", create_id)
|
|
end
|
|
end
|
|
|
|
function plugin_unload(plug_env)
|
|
print("now running unload plugin example-2 function, plugin id is ", plug_env.id)
|
|
|
|
end |