|  |  | 
 |  |  | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSONObject; | 
 |  |  | import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatch; | 
 |  |  | import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatchStatus; | 
 |  |  | import com.genersoft.iot.vmp.gb28181.bean.Device; | 
 |  |  | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 
 |  |  | import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; | 
 |  |  | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | 
 |  |  | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; | 
 |  |  | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private DeferredResultHolder deferredResultHolder; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private AudioBroadcastManager audioBroadcastManager; | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public void afterPropertiesSet() throws Exception { | 
 |  |  |         responseMessageHandler.addHandler(cmdType, this); | 
 |  |  | 
 |  |  |     public void handForDevice(RequestEvent evt, Device device, Element rootElement) { | 
 |  |  |         try { | 
 |  |  |             String channelId = getText(rootElement, "DeviceID"); | 
 |  |  |             String key = DeferredResultHolder.CALLBACK_CMD_BROADCAST + device.getDeviceId() + channelId; | 
 |  |  |             // 回复200 OK | 
 |  |  |             responseAck(evt, Response.OK); | 
 |  |  |             // 此处是对本平台发出Broadcast指令的应答 | 
 |  |  |             JSONObject json = new JSONObject(); | 
 |  |  |             XmlUtil.node2Json(rootElement, json); | 
 |  |  |             if (logger.isDebugEnabled()) { | 
 |  |  |                 logger.debug(json.toJSONString()); | 
 |  |  |             if (!audioBroadcastManager.exit(device.getDeviceId(), channelId)) { | 
 |  |  |                 // 回复410 | 
 |  |  |                 responseAck(evt, Response.GONE); | 
 |  |  |                 return; | 
 |  |  |             } | 
 |  |  |             RequestMessage msg = new RequestMessage(); | 
 |  |  |             msg.setKey(key); | 
 |  |  |             msg.setData(json); | 
 |  |  |             deferredResultHolder.invokeAllResult(msg); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |             logger.info("收到语音广播的回复:{}/{}", device.getDeviceId(), channelId ); | 
 |  |  |             AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(device.getDeviceId(), channelId); | 
 |  |  |             audioBroadcastCatch.setStatus(AudioBroadcastCatchStatus.WaiteInvite); | 
 |  |  |             audioBroadcastManager.update(audioBroadcastCatch); | 
 |  |  |             responseAck(evt, Response.OK); | 
 |  |  |         } catch (ParseException | SipException | InvalidArgumentException e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } |