summaryrefslogtreecommitdiff
path: root/example/plugin/example_plugin_regist.lua
blob: 552e4af1009a2aef3b8a1ae55bc2c1efd673c2cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function plugin_ctx_new(sess, plug_env, sess_context)
    print("now begin to create new ctx context example regist")
    sess_context.data = "this is example regist sess context data"
    print("session data is", sess_context.data)
end

function plugin_ctx_free(sess, sess_context, plug_env)
    print("now begin to free ctx context example regist")
    print("session data is", sess_context.data)
end

function plugin_load(stellar, plug_env)
    print("now load lua plugin example regist")
    print("this example aims to test regist function")
    plug_env.data = "my example regist plugin env"
    --[[ 由于未订阅消息, 注册函数应该永远不会触发 ]]
    plug_env.id = session_plugin.register(stellar, plugin_ctx_new, plugin_ctx_free, plug_env)
    print("plugin env data is", plug_env.data)
    print("after regist, plugin id is", plug_env.id)
end

function plugin_unload(plug_env)
    print("now unload lua plugin example regist")
    print("plugin env data is", plug_env.data)
end