private void sendRequest(EventName reqSignal, RequestedEvent[] reqEvents) { final EventName[] signal = new EventName[1]; signal[0] = reqSignal; final RequestIdentifier requestId = new RequestIdentifier(DEFAULT_REQUEST_ID); final NotificationRequest request = new NotificationRequest(self(), id, requestId); request.setNotifiedEntity(agent); request.setRequestedEvents(reqEvents); request.setSignalRequests(signal); gateway.tell(request, self()); }
@Override public JainMgcpCommandEvent decodeCommand(byte[] data,SplitDetails[] message) throws ParseException { command = new NotificationRequest(source != null ? source : stack, endpoint, new RequestIdentifier("0")); command.setTransactionHandle(remoteTID); try { (new CommandContentHandle()).parse(data,message); } catch (Exception e) { e.printStackTrace(); throw new ParseException(e.getMessage(), -1); } NotifiedEntity notifiedEntity = command.getNotifiedEntity(); if (command.getNotifiedEntity() != null) this.stack.provider.setNotifiedEntity(notifiedEntity); return 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(); }
public void header(String header) throws ParseException { command = new NotificationRequest(source != null ? source : stack, endpoint, new RequestIdentifier("0")); command.setTransactionHandle(remoteTID); }
public void param(String name, String value) throws ParseException { if (name.equalsIgnoreCase("N")) { command.setNotifiedEntity(utils.decodeNotifiedEntity(value, true)); } else if (name.equalsIgnoreCase("X")) { command.setRequestIdentifier(new RequestIdentifier(value)); } else if (name.equalsIgnoreCase("R")) { command.setRequestedEvents(utils.decodeRequestedEventList(value)); } else if (name.equalsIgnoreCase("S")) { command.setSignalRequests(utils.decodeEventNames(value)); } else if (name.equalsIgnoreCase("T")) { command.setDetectEvents(utils.decodeEventNames(value)); } else if (name.equalsIgnoreCase("D")) { command.setDigitMap(new DigitMap(value)); } }
private void stopRecording() { // generate request identifier and transaction ID RequestIdentifier reqID = parent.nextRequestID(); int txID = parent.getMediaSession().getDriver().getNextTxID(); // constructs request NotificationRequest req = new NotificationRequest(this, parent.getEndpoint().getIdentifier(), reqID); req.setTransactionHandle(txID); DriverImpl driver=parent.getMediaSession().getDriver(); req.setNotifiedEntity(driver.getCallAgent()); driver.attach(txID, this); driver.attach(reqID, this); driver.send(req); }
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); }
return; case SuccessResponse: if (this.endpointId.equals(nRequest.getEndpointIdentifier().toString())) { processRequestedEvents(nRequest.getNotifiedEntity(), nRequest.getRequestedEvents()); } else if (isWildCardEndpointName(nRequest.getEndpointIdentifier().toString())) {
protected void notificationResponse(final Object message, final ActorRef sender) { final ActorRef self = self(); final NotificationRequest rqnt = (NotificationRequest) message; EventName[] events = rqnt.getSignalRequests(); System.out.println(rqnt.toString()); ReturnCode code = null; if (failResponse) { final int transaction = rqnt.getTransactionHandle(); response.setTransactionHandle(transaction); try {
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); }
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 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 }); }
case StringFunctions.HIGH_N_BYTE: NotifiedEntity n = NotifiedEntityHandler.decode(data,value.getOffset(),value.getLength(), true); command.setNotifiedEntity(n); break; case StringFunctions.LOW_X_BYTE: case StringFunctions.HIGH_X_BYTE: command.setRequestIdentifier(new RequestIdentifier(new String(data,value.getOffset(),value.getLength()))); break; case StringFunctions.LOW_R_BYTE: case StringFunctions.HIGH_R_BYTE: command.setRequestedEvents(RequestedEventHandler.decodeList(data,value.getOffset(),value.getLength())); break; case StringFunctions.LOW_S_BYTE: case StringFunctions.HIGH_S_BYTE: command.setSignalRequests(EventNameHandler.decodeList(data,value.getOffset(),value.getLength())); break; case StringFunctions.LOW_T_BYTE: case StringFunctions.HIGH_T_BYTE: command.setDetectEvents(EventNameHandler.decodeList(data,value.getOffset(),value.getLength())); break; case StringFunctions.LOW_D_BYTE: case StringFunctions.HIGH_D_BYTE: command.setDigitMap(DigitMapHandler.decode(data,value.getOffset(),value.getLength())); break; default:
private void requestStop() { //generate request identifier and transaction ID RequestIdentifier reqID = parent.nextRequestID(); int txID = parent.getMediaSession().getDriver().getNextTxID(); //constructs request NotificationRequest req = new NotificationRequest(this, parent.getEndpoint().getIdentifier(), reqID); req.setTransactionHandle(txID); DriverImpl driver=parent.getMediaSession().getDriver(); req.setNotifiedEntity(driver.getCallAgent()); driver.attach(txID, this); driver.attach(reqID, this); driver.send(req); }
@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); } }
protected void notificationResponse(final Object message, final ActorRef sender) { final ActorRef self = self(); final NotificationRequest rqnt = (NotificationRequest) message; EventName[] events = rqnt.getSignalRequests(); System.out.println(rqnt.toString()); ReturnCode code = null; if (failResponse) { final int transaction = rqnt.getTransactionHandle(); response.setTransactionHandle(transaction); try {
public void stop() { final List<State> possibleStates = new ArrayList<State>(); possibleStates.add(PLAY); possibleStates.add(PLAY_COLLECT); possibleStates.add(PLAY_RECORD); possibleStates.add(IDLE); assertState(possibleStates); // Create the signal. final EventName[] signal = new EventName[1]; signal[0] = new EventName(PACKAGE_NAME, AUMgcpEvent.aues); // Create notification request. requestId = server.generateRequestIdentifier(); final NotificationRequest request = new NotificationRequest(this, endpointId, requestId); request.setSignalRequests(signal); request.setNotifiedEntity(server.getCallAgent()); request.setRequestedEvents(REQUESTED_EVENTS); // Send the request. server.sendCommand(request, this); setState(STOP); }
case StringFunctions.HIGH_N_BYTE: NotifiedEntity n = NotifiedEntityHandler.decode(data,value.getOffset(),value.getLength(), true); command.setNotifiedEntity(n); break; case StringFunctions.LOW_X_BYTE: case StringFunctions.HIGH_X_BYTE: command.setRequestIdentifier(new RequestIdentifier(new String(data,value.getOffset(),value.getLength()))); break; case StringFunctions.LOW_R_BYTE: case StringFunctions.HIGH_R_BYTE: command.setRequestedEvents(RequestedEventHandler.decodeList(data,value.getOffset(),value.getLength())); break; case StringFunctions.LOW_S_BYTE: case StringFunctions.HIGH_S_BYTE: command.setSignalRequests(EventNameHandler.decodeList(data,value.getOffset(),value.getLength())); break; case StringFunctions.LOW_T_BYTE: case StringFunctions.HIGH_T_BYTE: command.setDetectEvents(EventNameHandler.decodeList(data,value.getOffset(),value.getLength())); break; case StringFunctions.LOW_D_BYTE: case StringFunctions.HIGH_D_BYTE: command.setDigitMap(DigitMapHandler.decode(data,value.getOffset(),value.getLength())); break; default:
private void stopRecording() { // generate request identifier and transaction ID RequestIdentifier reqID = parent.nextRequestID(); int txID = parent.getMediaSession().getDriver().getNextTxID(); // constructs request NotificationRequest req = new NotificationRequest(this, parent.getEndpoint().getIdentifier(), reqID); req.setTransactionHandle(txID); DriverImpl driver=parent.getMediaSession().getDriver(); req.setNotifiedEntity(driver.getCallAgent()); driver.attach(txID, this); driver.attach(reqID, this); driver.send(req); }
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); if (evt.getNotifiedEntity() != null) totalLength+=NotifiedEntityHandler.encode(array,totalLength,evt.getNotifiedEntity()); array[totalLength++]=StringFunctions.NEWLINE_BYTE; byte[] requestBytes=evt.getRequestIdentifier().toString().getBytes(); System.arraycopy(requestBytes, 0, array,totalLength, requestBytes.length); totalLength+=requestBytes.length; array[totalLength++]=StringFunctions.NEWLINE_BYTE; if (evt.getDigitMap() != null) totalLength+=DigitMapHandler.encode(array,totalLength,evt.getDigitMap()); array[totalLength++]=StringFunctions.NEWLINE_BYTE; if (evt.getSignalRequests() != null) totalLength+=EventNameHandler.encodeList(array,totalLength,evt.getSignalRequests()); array[totalLength++]=StringFunctions.NEWLINE_BYTE; if (evt.getRequestedEvents() != null) totalLength+=RequestedEventHandler.encodeList(array,totalLength,evt.getRequestedEvents());