panlinlin
2020-12-27 6968839f21fb05bf6e3204c2040ee47130006cd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.genersoft.iot.vmp.gb28181.event;
 
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
 
import javax.sip.ResponseEvent;
import javax.sip.message.Request;
import java.util.EventObject;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
 
@Component
public class SipSubscribe {
 
    private final static Logger logger = LoggerFactory.getLogger(SipSubscribe.class);
 
    private Map<String, SipSubscribe.Event> allSubscribes = new ConcurrentHashMap<>();
 
    public interface Event {
        void response(ResponseEvent event);
    }
 
    public void addSubscribe(String key, SipSubscribe.Event event) {
        allSubscribes.put(key, event);
    }
 
    public SipSubscribe.Event getSubscribe(String key) {
        return allSubscribes.get(key);
    }
 
    public int getSize(){
        return allSubscribes.size();
    }
}