summaryrefslogtreecommitdiff
path: root/test/plugin/example_plugin_regist.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/plugin/example_plugin_regist.lua')
-rw-r--r--test/plugin/example_plugin_regist.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/plugin/example_plugin_regist.lua b/test/plugin/example_plugin_regist.lua
new file mode 100644
index 0000000..552e4af
--- /dev/null
+++ b/test/plugin/example_plugin_regist.lua
@@ -0,0 +1,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 \ No newline at end of file