package com.njzscloud.common.localizer.jt808.util;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class FlowId {
    private static final Map<String, Integer> flowId = new ConcurrentHashMap<>();

    public static synchronized int next(String terminalId, int messageId) {
        String key = terminalId + "_" + messageId;
        Integer i = flowId.get(key);
        if (i == null || i >= 0xFFFF) {
            i = 0;
        }
        i++;
        flowId.put(key, i);
        return i;
    }
}
