diff options
| author | niubinghui <[email protected]> | 2024-10-08 15:13:06 +0800 |
|---|---|---|
| committer | niubinghui <[email protected]> | 2024-10-08 15:13:06 +0800 |
| commit | ad865134dc73d7db04792d51fe267df650e0808a (patch) | |
| tree | 0f2d7f4304dc272d0603454567ca18da16a52ebe /test/plugin/example_plugin_message.lua | |
| parent | 6417137294d60bdcef91c813601a9271c7b62261 (diff) | |
【新增】
修改部分测试代码
Diffstat (limited to 'test/plugin/example_plugin_message.lua')
| -rw-r--r-- | test/plugin/example_plugin_message.lua | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/test/plugin/example_plugin_message.lua b/test/plugin/example_plugin_message.lua index 6515bdc..e6d8967 100644 --- a/test/plugin/example_plugin_message.lua +++ b/test/plugin/example_plugin_message.lua @@ -8,19 +8,22 @@ end function on_message(sess, topic_id, msg, sess_context, env) -- print("message call on message function, id", topic_id) - print("message is", msg.data) + print("get message is", topic_id, msg.data) end function plugin_load(stellar, plug_env) - print("now begin to load plugin example messaga") - print("this example aims to test topic functions") - plug_env.st = stellar plug_env.id = session_plugin.register(stellar, plugin_ctx_new, plugin_ctx_free, plug_env) plug_env.data = "this is message example plug env data" --[[ 订阅TOPIC_SESSION_STAT, 并完成函数注册 ]] - test_topic_id = session_mq.get_topic_id(stellar, "TOPIC_SESSION_STAT") + test_topic_id = session_mq.get_topic_id(stellar, "LUA_TOPIC_SESSION_STAT") + if (test_topic_id < 0) + then + --[[ 该消息未创建, 创建该topic ]] + test_topic_id = session_mq.create_topic(stellar, "LUA_TOPIC_SESSION_STAT", nil, nil) + print("create topic is", test_topic_id) + end session_mq.subscribe_topic(stellar, test_topic_id, on_message, plug_env.id) end |
