public RequestIdentifier getUniqueRequestIdentifier() { return new RequestIdentifier(Long.toHexString((long)requestIdentifierCounter.incrementAndGet()-(long)Integer.MIN_VALUE)); }
/** * Attaches listener to the specific request. * * @param reqID the request identifier. * @param listener listener to be attached. */ public void attach(RequestIdentifier reqID, JainMgcpListener listener) { this.requestListeners.put(reqID.toString().trim(), listener); }
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 }); }
public RequestIdentifier getUniqueRequestIdentifier() { return new RequestIdentifier(Long.toHexString((long)requestIdentifierCounter.incrementAndGet()-(long)Integer.MIN_VALUE)); }
/** * Attaches listener to the specific request. * * @param reqID the request identifier. * @param listener listener to be attached. */ public void attach(RequestIdentifier reqID, JainMgcpListener listener) { this.requestListeners.put(reqID.toString().trim(), listener); }
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); } } }
public RequestIdentifier getUniqueRequestIdentifier() { long current = -1; boolean b = true; while (b) { current = requestIdentifierCounter.get(); if (current == Long.MAX_VALUE) { b = !requestIdentifierCounter.compareAndSet(current, 1); } else { b = !requestIdentifierCounter.compareAndSet(current, current + 1); } } return new RequestIdentifier(Long.toHexString(current)); }
/** * Deattaches listeners related to specific request. * * @param reqID the request identifier. */ public void deattach(RequestIdentifier reqID) { this.requestListeners.remove(reqID.toString().trim()); }
public void header(String header) throws ParseException { command = new NotificationRequest(source != null ? source : stack, endpoint, new RequestIdentifier("0")); command.setTransactionHandle(remoteTID); }
/** * Deattaches listeners related to specific request. * * @param reqID the request identifier. */ public void deattach(RequestIdentifier reqID) { this.requestListeners.remove(reqID.toString().trim()); }
/** * Generates unique request identifier. * * @return request identifier object. */ public RequestIdentifier nextRequestID() { return new RequestIdentifier(Integer.toString(session.getUniqueReqID())); }
public void processMgcpCommandEvent(JainMgcpCommandEvent evt) { //we are expecting two types of commands: //-delete connection notification (in case of failure connection on server side) //-notify switch (evt.getObjectIdentifier()) { case Constants.CMD_DELETE_CONNECTION : //TODO: handle delete connection request from server; break; case Constants.CMD_NOTIFY : Notify event = (Notify) evt; //if there is attached handler deligate call to it if (this.requestListeners.containsKey(event.getRequestIdentifier().toString().trim())) { requestListeners.get(event.getRequestIdentifier().toString().trim()).processMgcpCommandEvent(evt); } //send response to this transaction; NotifyResponse response = new NotifyResponse(this, ReturnCode.Transaction_Executed_Normally); response.setTransactionHandle(evt.getTransactionHandle()); this.send(response); break; default : } }
/** * Generates unique request identifier. * * @return request identifier object. */ public RequestIdentifier nextRequestID() { return new RequestIdentifier(Integer.toString(session.getUniqueReqID())); }
public void processMgcpCommandEvent(JainMgcpCommandEvent evt) { //we are expecting two types of commands: //-delete connection notification (in case of failure connection on server side) //-notify switch (evt.getObjectIdentifier()) { case Constants.CMD_DELETE_CONNECTION : //TODO: handle delete connection request from server; break; case Constants.CMD_NOTIFY : Notify event = (Notify) evt; //if there is attached handler deligate call to it if (this.requestListeners.containsKey(event.getRequestIdentifier().toString().trim())) { requestListeners.get(event.getRequestIdentifier().toString().trim()).processMgcpCommandEvent(evt); } //send response to this transaction; NotifyResponse response = new NotifyResponse(this, ReturnCode.Transaction_Executed_Normally); response.setTransactionHandle(evt.getTransactionHandle()); this.send(response); break; default : } }
public void header(String header) throws ParseException { command = new Notify(source != null ? source : stack, endpoint, new RequestIdentifier("0"), new EventName[] {}); command.setTransactionHandle(remoteTID); }
@Override public void processMgcpCommandEvent(final JainMgcpCommandEvent event) { final int value = event.getObjectIdentifier(); switch (value) { case Constants.CMD_NOTIFY: { final Notify notify = (Notify) event; final String id = notify.getRequestIdentifier().toString(); final ActorRef listener; if (isPartialNotify(notify)) { listener = notificationListeners.get(id); } else { listener = notificationListeners.remove(id); } if (listener != null) { listener.tell(notify, self()); } } } }
public RequestIdentifier generateRequestIdentifier() { assertState(RUNNING); return new RequestIdentifier(Integer.toString((int)requestId.getAndIncrement())); }
byte[] requestBytes=evt.getRequestIdentifier().toString().getBytes(); System.arraycopy(requestBytes, 0, array,totalLength, requestBytes.length); totalLength+=requestBytes.length;
@Override public JainMgcpCommandEvent decodeCommand(byte[] data,SplitDetails[] message) throws ParseException { command = new Notify(source != null ? source : stack, endpoint, new RequestIdentifier("0"), new EventName[] {}); command.setTransactionHandle(remoteTID); try { (new CommandContentHandle()).parse(data,message); } catch (Exception e) { throw new ParseException(e.getMessage(), -1); } return command; }