@Override public String encode(JainMgcpCommandEvent event) { RestartInProgress rsip = (RestartInProgress) event; StringBuffer message = new StringBuffer(); message.append("RSIP ").append(event.getTransactionHandle()).append(SINGLE_CHAR_SPACE).append( rsip.getEndpointIdentifier()).append(SINGLE_CHAR_SPACE).append(MGCP_VERSION).append(NEW_LINE); message.append("RM:").append(rsip.getRestartMethod()).append(NEW_LINE); if (rsip.getRestartDelay() != 0) { message.append("RD:").append(rsip.getRestartDelay()).append(NEW_LINE); } if (rsip.getReasonCode() != null) { message.append("E:").append(rsip.getReasonCode()).append(NEW_LINE); } return message.toString(); }
@Override public JainMgcpResponseEvent getProvisionalResponse() { DeleteConnectionResponse provisionalResponse = null; if (!sent) { provisionalResponse = new DeleteConnectionResponse(source != null ? source : stack,ReturnCode.Transaction_Being_Executed); provisionalResponse.setTransactionHandle(commandEvent.getTransactionHandle()); } return provisionalResponse; }
@Override public JainMgcpResponseEvent getProvisionalResponse() { DeleteConnectionResponse provisionalResponse = null; if (!sent) { provisionalResponse = new DeleteConnectionResponse(source != null ? source : stack, ReturnCode.Transaction_Being_Executed); provisionalResponse.setTransactionHandle(commandEvent.getTransactionHandle()); } return provisionalResponse; }
@Override public JainMgcpResponseEvent getProvisionalResponse() { DeleteConnectionResponse provisionalResponse = null; if (!sent) { provisionalResponse = new DeleteConnectionResponse(source != null ? source : stack,ReturnCode.Transaction_Being_Executed); provisionalResponse.setTransactionHandle(commandEvent.getTransactionHandle()); } return provisionalResponse; }
@Override public String encode(JainMgcpCommandEvent event) { Notify notify = (Notify) event; StringBuffer message = new StringBuffer(); message.append("NTFY ").append(event.getTransactionHandle()).append(SINGLE_CHAR_SPACE).append( notify.getEndpointIdentifier()).append(MGCP_VERSION).append(NEW_LINE); if (notify.getNotifiedEntity() != null) { message.append("N: ").append(notify.getNotifiedEntity()).append(NEW_LINE); } message.append("X: ").append(notify.getRequestIdentifier()).append(NEW_LINE); Utils utils = utilsFactory.allocate(); message.append("O: ").append(utils.encodeEventNames(notify.getObservedEvents())).append(NEW_LINE); utilsFactory.deallocate(utils); return message.toString(); }
@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 int encode(JainMgcpCommandEvent event,byte[] array) { EndpointConfiguration evt = (EndpointConfiguration) event; int totalLength=5; System.arraycopy(COMMAND_NAME, 0, array, 0, 4); array[4]=StringFunctions.SPACE_BYTE; 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+=MGCP_VERSION.length; array[totalLength++]=StringFunctions.NEWLINE_BYTE; // encode mandatory parameters array[totalLength++]=StringFunctions.HIGH_B_BYTE; array[totalLength++]=StringFunctions.COLON_BYTE; totalLength+=BearerInformationHandler.encode(array,totalLength,evt.getBearerInformation()); array[totalLength++]=StringFunctions.NEWLINE_BYTE; return totalLength; }
public int encode(JainMgcpCommandEvent event,byte[] array) { EndpointConfiguration evt = (EndpointConfiguration) event; int totalLength=5; System.arraycopy(COMMAND_NAME, 0, array, 0, 4); array[4]=StringFunctions.SPACE_BYTE; 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+=MGCP_VERSION.length; array[totalLength++]=StringFunctions.NEWLINE_BYTE; // encode mandatory parameters array[totalLength++]=StringFunctions.HIGH_B_BYTE; array[totalLength++]=StringFunctions.COLON_BYTE; totalLength+=BearerInformationHandler.encode(array,totalLength,evt.getBearerInformation()); array[totalLength++]=StringFunctions.NEWLINE_BYTE; return totalLength; }
@Override public int encode(JainMgcpCommandEvent event,byte[] array) { AuditEndpoint evt = (AuditEndpoint) event; int totalLength=5; System.arraycopy(COMMAND_NAME, 0, array, 0, 4); array[4]=StringFunctions.SPACE_BYTE; 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+=MGCP_VERSION.length; array[totalLength++]=StringFunctions.NEWLINE_BYTE; InfoCode[] requestedInfos = evt.getRequestedInfo(); if (requestedInfos != null) { array[totalLength++]=StringFunctions.HIGH_F_BYTE; array[totalLength++]=StringFunctions.COLON_BYTE; array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=InfoCodeHandler.encodeList(array,totalLength,requestedInfos); array[totalLength++]=StringFunctions.NEWLINE_BYTE; } return totalLength; }
@Override public int encode(JainMgcpCommandEvent event,byte[] array) { AuditEndpoint evt = (AuditEndpoint) event; int totalLength=5; System.arraycopy(COMMAND_NAME, 0, array, 0, 4); array[4]=StringFunctions.SPACE_BYTE; 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+=MGCP_VERSION.length; array[totalLength++]=StringFunctions.NEWLINE_BYTE; InfoCode[] requestedInfos = evt.getRequestedInfo(); if (requestedInfos != null) { array[totalLength++]=StringFunctions.HIGH_F_BYTE; array[totalLength++]=StringFunctions.COLON_BYTE; array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=InfoCodeHandler.encodeList(array,totalLength,requestedInfos); array[totalLength++]=StringFunctions.NEWLINE_BYTE; } return totalLength; }
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 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 : } }
System.arraycopy(COMMAND_NAME, 0, array, 0, 4); array[4]=StringFunctions.SPACE_BYTE; totalLength+=StringFunctions.encodeInt(array,5,event.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=EndpointIdentifierHandler.encode(array,totalLength,evt.getEndpointIdentifier());
System.arraycopy(COMMAND_NAME, 0, array, 0, 4); array[4]=StringFunctions.SPACE_BYTE; totalLength+=StringFunctions.encodeInt(array,5,event.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=EndpointIdentifierHandler.encode(array,totalLength,evt.getEndpointIdentifier());
System.arraycopy(COMMAND_NAME, 0, array, 0, 4); array[4]=StringFunctions.SPACE_BYTE; totalLength+=StringFunctions.encodeInt(array,5,event.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=EndpointIdentifierHandler.encode(array,totalLength,evt.getEndpointIdentifier());
System.arraycopy(COMMAND_NAME, 0, array, 0, 4); array[4]=StringFunctions.SPACE_BYTE; totalLength+=StringFunctions.encodeInt(array,5,event.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=EndpointIdentifierHandler.encode(array,totalLength,evt.getEndpointIdentifier());
response.setTransactionHandle(command.getTransactionHandle()); server.sendResponse(response);
throw new IllegalArgumentException("Could not send type of the message yet"); response.setTransactionHandle(command.getTransactionHandle()); JainMgcpEvent[] events = { response }; sendMgcpEvents(events);
System.arraycopy(COMMAND_NAME, 0, array, 0, 4); array[4]=StringFunctions.SPACE_BYTE; totalLength+=StringFunctions.encodeInt(array,5,event.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=EndpointIdentifierHandler.encode(array,totalLength,rsip.getEndpointIdentifier());
System.arraycopy(COMMAND_NAME, 0, array, 0, 4); array[4]=StringFunctions.SPACE_BYTE; totalLength+=StringFunctions.encodeInt(array,5,event.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=EndpointIdentifierHandler.encode(array,totalLength,rsip.getEndpointIdentifier());