Called before delivering a message to a subscriber. Receives pub
and sub
, the tables returned from the publish
and subscribe
functions. Modifications to these tables affect only this subscriber, not others receiving the same message. Typically used for routing and subscriber-specific adjustments.
NOTE: Changes to the inner req
tables will not be preserved.
function message(pub, sub)
-- Subscriber-specific logic such as routing, message modifications, etc.
-- Returning `nil` (or just nothing at all) will prevent this
-- subscriber from receiving the message.
-- Returning the `pub` table to the server will continue with
-- delivery of the (possibly modified) SSE message to the subscriber.
return pub
end