tzssangglass commented on code in PR #7043: URL: https://github.com/apache/apisix/pull/7043#discussion_r872236236
########## apisix/core/pubsub.lua: ########## @@ -58,23 +58,42 @@ local function init_pb_state() end +-- parse command name and parameters from client message +local function get_cmd(data) + for key, value in pairs(data) do + -- There are sequence and command properties in the data, + -- select the handler according to the command value. + if key ~= "sequence" then + return key, value + end + end +end + + +-- send generic response to client +local function send_resp(ws, sequence, data) + data.sequence = sequence + local ok, encoded = pcall(pb.encode, "PubSubResp", data) + if not ok or not data then Review Comment: `not data`? ########## apisix/core/pubsub.lua: ########## @@ -119,8 +138,8 @@ end -- no error exists. -- -- @function core.pubsub.on --- @tparam string command to add callback --- @tparam function handler callback on receipt of command +-- @tparam string command The command to add callback. +-- @tparam func handler The callback function on receipt of command. Review Comment: `-- @tparam function` ? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
