Lawrence
2020-12-16 44d216100b45c3337c593ee82ee68e7e0f35d24b
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
38
39
40
41
42
43
44
package com.genersoft.iot.vmp.gb28181.transmit.callback;
 
import java.util.HashMap;
import java.util.Map;
 
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.async.DeferredResult;
 
/**    
 * @Description:TODO(这里用一句话描述这个类的作用)   
 * @author: swwheihei
 * @date:   2020年5月8日 下午7:59:05     
 */
@Component
public class DeferredResultHolder {
    
    public static final String CALLBACK_CMD_DEVICEINFO = "CALLBACK_DEVICEINFO";
    
    public static final String CALLBACK_CMD_CATALOG = "CALLBACK_CATALOG";
    
    public static final String CALLBACK_CMD_RECORDINFO = "CALLBACK_RECORDINFO";
 
    public static final String CALLBACK_CMD_PlAY = "CALLBACK_PLAY";
 
    private Map<String, DeferredResult> map = new HashMap<String, DeferredResult>();
    
    public void put(String key, DeferredResult result) {
        map.put(key, result);
    }
    
    public DeferredResult get(String key) {
        return map.get(key);
    }
    
    public void invokeResult(RequestMessage msg) {
        DeferredResult result = map.get(msg.getId());
        if (result == null) {
            return;
        }
        result.setResult(new ResponseEntity<>(msg.getData(),HttpStatus.OK));
    }
}