【新增】
修改部分测试代码
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user