catchup(sub, last_event_id)

    Called immediately after a client subscribes. If the client provides a Last-Event-ID, either through the Last-Event-ID: request header or as a query parameter (?last_event_id=), this function should attempt to retrieve missed messages. If both are provided, the header takes precedence. The function may return nil or an array of SSE messages to "catch-up" the subscriber with any messages they may have missed due to reconnection or to provide recent message history. If last_event_id is nil or no messages are available, the function may return nil instead of an empty array.

    NOTE: The message(pub, sub) function will not be called for messages delivered from the catchup(sub, last_event_id) function.

    function catchup(sub, last_event_id)
      -- last_event_id might be nil if the client did not provide it
      local msgs = {}
    
      -- For instance, "catch-up" subscriber with the 10 most recent messages
      for i=1,10 do
        table.insert(msgs, {
          id = "some-id-" .. i,
          event = "some-event",
          data = "some data"
        })
      end
    
      return msgs
    end