private void send(final Object message, final ActorRef sender) { final JainMgcpCommandEvent command = (JainMgcpCommandEvent) message; final int transactionId = (int) transactionIdPool.get(); command.setTransactionHandle(transactionId); responseListeners.put(transactionId, sender); if (NotificationRequest.class.equals(command.getClass())) { final NotificationRequest request = (NotificationRequest) command; final String id = Long.toString(requestIdPool.get()); request.getRequestIdentifier().setRequestIdentifier(id); notificationListeners.put(id, sender); } provider.sendMgcpEvents(new JainMgcpEvent[] { command }); }
@Override public String encode(JainMgcpCommandEvent event) { Utils utils = utilsFactory.allocate(); NotificationRequest req = (NotificationRequest) event; StringBuffer buffer = new StringBuffer(); buffer.append("RQNT ").append(event.getTransactionHandle()).append(SINGLE_CHAR_SPACE).append( req.getEndpointIdentifier()).append(SINGLE_CHAR_SPACE).append(MGCP_VERSION).append(NEW_LINE); if (req.getNotifiedEntity() != null) { buffer.append("N:").append(req.getNotifiedEntity()).append(NEW_LINE); } buffer.append("X:").append(req.getRequestIdentifier()).append(NEW_LINE); if (req.getDigitMap() != null) { buffer.append("D:").append(req.getDigitMap()).append(NEW_LINE); } if (req.getSignalRequests() != null) { buffer.append("S:").append(utils.encodeEventNames(req.getSignalRequests())).append(NEW_LINE); } if (req.getRequestedEvents() != null) { buffer.append("R:").append(utils.encodeRequestedEvents(req.getRequestedEvents())).append(NEW_LINE); } if (req.getDetectEvents() != null) { buffer.append("T:").append(utils.encodeEventNames(req.getDetectEvents())).append(NEW_LINE); } utilsFactory.deallocate(utils); return buffer.toString(); }
private void send (final Object message, final ActorRef sender) { final JainMgcpCommandEvent command = (JainMgcpCommandEvent) message; final int transactionId = (int) transactionIdPool.get(); command.setTransactionHandle(transactionId); respond(message, sender); EventName[] events = null; if (message instanceof NotificationRequest) { final NotificationRequest rqnt = (NotificationRequest) message; events = rqnt.getSignalRequests(); if (events != null && events[0].getEventIdentifier().getName().equalsIgnoreCase("pr")) { recordingRqnt = rqnt; recordingRqntSender = sender(); } } if (events != null && !events[0].getEventIdentifier().getName().equalsIgnoreCase("pr")) { if (NotificationRequest.class.equals(command.getClass())) { final NotificationRequest request = (NotificationRequest) command; final String id = Long.toString(requestIdPool.get()); request.getRequestIdentifier().setRequestIdentifier(id); notify(request, sender); } } }
private void notify(final Object message, final ActorRef sender) { final ActorRef self = self(); final NotificationRequest request = (NotificationRequest) message; final MgcpEvent event = AUMgcpEvent.auoc.withParm("rc=100 dc=1"); final EventName[] events = {new EventName(AUPackage.AU, event)}; final Notify notify = new Notify(this, request.getEndpointIdentifier(), request.getRequestIdentifier(), events); notify.setTransactionHandle((int) transactionIdPool.get()); System.out.println(notify.toString()); sender.tell(notify, self); }
protected void notify (final Object message, final ActorRef sender) { final ActorRef self = self(); final NotificationRequest request = (NotificationRequest) message; MgcpEvent event = null; if (request.getSignalRequests()[0].getEventIdentifier().getName().equalsIgnoreCase("es") || request.getSignalRequests()[0].getEventIdentifier().getName().equalsIgnoreCase("pr")) { //Looks like this is either an RQNT AU/ES or //recording max length reached and we got the original recording RQNT event = AUMgcpEvent.auoc.withParm("AU/pr ri=file://" + recordingFile.toPath() + " rc=100 dc=1"); } else { event = AUMgcpEvent.auoc.withParm("rc=100 dc=1"); } final EventName[] events = {new EventName(AUPackage.AU, event)}; final Notify notify = new Notify(this, request.getEndpointIdentifier(), request.getRequestIdentifier(), events); notify.setTransactionHandle((int) transactionIdPool.get()); System.out.println(notify.toString()); sender.tell(notify, self); }
@Override protected void notify(Object message, ActorRef sender) { final ActorRef self = self(); final NotificationRequest request = (NotificationRequest) message; MgcpEvent event = null; if (request.getSignalRequests()[0].getEventIdentifier().getName().equalsIgnoreCase("es") || request.getSignalRequests()[0].getEventIdentifier().getName().equalsIgnoreCase("pr")) { //Looks like this is either an RQNT AU/ES or //recording max length reached and we got the original recording RQNT event = AUMgcpEvent.auoc.withParm("AU/pr ri=file://" + recordingFile.toPath() + " rc=100 dc=1"); } else { event = AUMgcpEvent.auoc.withParm("rc=100 dc=1"); if(!request.getSignalRequests()[0].getEventIdentifier().getParms().contains("ringing.wav")) { try { Thread.sleep(2000); } catch (Exception e){ logger.error(e.toString()); } } } final EventName[] events = {new EventName(AUPackage.AU, event)}; final Notify notify = new Notify(this, request.getEndpointIdentifier(), request.getRequestIdentifier(), events); notify.setTransactionHandle((int) transactionIdPool.get()); System.out.println(notify.toString()); sender.tell(notify, self); } }
byte[] requestBytes=evt.getRequestIdentifier().toString().getBytes(); System.arraycopy(requestBytes, 0, array,totalLength, requestBytes.length); totalLength+=requestBytes.length;
byte[] requestBytes=evt.getRequestIdentifier().toString().getBytes(); System.arraycopy(requestBytes, 0, array,totalLength, requestBytes.length); totalLength+=requestBytes.length;