local TXSE = require("txse-lib")

-- Route payload based on message type byte case
-- Upper case (A-Z, 65-90) = SEED, Lower case (a-z, 97-122) = FEED (or compatible SEED)
local function route_payload(buffer, pinfo, tree_item)
    if buffer:len() < 1 then
        return
    end
    local msg_type = buffer(0, 1):uint()
    if msg_type >= 65 and msg_type <= 90 then
        TXSE.dissector("txse_seed"):call(buffer:tvb(), pinfo, tree_item)
    elseif msg_type >= 97 and msg_type <= 122 then
        TXSE.dissector("txse_feed"):call(buffer:tvb(), pinfo, tree_item)
    end
end

require("txse-rake-tcp-generated").register({
    payload_decoder = route_payload
})
