package com.inspect.ivs.constant;

import java.util.ArrayList;
import java.util.List;

public class IvsMediaPort {
    public static final List<Integer> unUsePoor = new ArrayList<>();
    public static final List<Integer> usedPoor = new ArrayList<>();

    public static Integer getPort() {
        Integer port = (Integer) unUsePoor.remove(0);
        usedPoor.add(port);

        while (usedPoor.size() > 50) {
            Integer expirePort = (Integer) usedPoor.remove(0);
            unUsePoor.add(expirePort);
        }

        return port;
    }

    static {
        for (int i = 30250; i < 30500; ++i) {
            unUsePoor.add(i);
        }

    }
}
