@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 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); } }
return; case SuccessResponse: if (this.endpointId.equals(nRequest.getEndpointIdentifier().toString())) { } else if (isWildCardEndpointName(nRequest.getEndpointIdentifier().toString())) {
totalLength+=StringFunctions.encodeInt(array,5,event.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=EndpointIdentifierHandler.encode(array,totalLength,evt.getEndpointIdentifier()); array[totalLength++]=StringFunctions.SPACE_BYTE; System.arraycopy(MGCP_VERSION, 0, array, totalLength, MGCP_VERSION.length);
totalLength+=StringFunctions.encodeInt(array,5,event.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=EndpointIdentifierHandler.encode(array,totalLength,evt.getEndpointIdentifier()); array[totalLength++]=StringFunctions.SPACE_BYTE; System.arraycopy(MGCP_VERSION, 0, array, totalLength, MGCP_VERSION.length);