/** * Receive notification of the header of a message. Parser will call * this method to report about header reading. * * @param header * the header from the message. */ public void header(String header) throws ParseException { command = new AuditEndpoint(source != null ? source : stack, endpoint); command.setTransactionHandle(remoteTID); }
@Override public String encode(JainMgcpCommandEvent event) { Utils utils = utilsFactory.allocate(); // encode message header AuditEndpoint evt = (AuditEndpoint) event; StringBuffer s = new StringBuffer(); s.append("AUEP ").append(evt.getTransactionHandle()).append(SINGLE_CHAR_SPACE).append( evt.getEndpointIdentifier()).append(MGCP_VERSION).append(NEW_LINE); // encode mandatory parameters InfoCode[] requestedInfos = evt.getRequestedInfo(); if (requestedInfos != null) { s.append("F: ").append(utils.encodeInfoCodeList(requestedInfos)); } utilsFactory.deallocate(utils); // return msg; return s.toString(); }
/** * Receive notification of the parameter of a message. Parser will call * this method to report about parameter reading. * * @param name * the name of the parameter * @param value * the value of the parameter. */ public void param(String name, String value) throws ParseException { if (name.equalsIgnoreCase("F")) { command.setRequestedInfo(utils.decodeInfoCodeList(value)); } else { logger.error("Unknown code " + name); } }
@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; }
@Override public JainMgcpCommandEvent decodeCommand(byte[] data,SplitDetails[] message) throws ParseException { command = new AuditEndpoint(source != null ? source : stack, endpoint); command.setTransactionHandle(remoteTID); try { (new CommandContentHandle()).parse(data,message); } catch (Exception e) { throw new ParseException(e.getMessage(), -1); } return command; }
/** * Receive notification of the parameter of a message. Parser will call * this method to report about parameter reading. * * @param name * the name of the parameter * @param value * the value of the parameter. */ public void param(byte[] data,SplitDetails name,SplitDetails value) throws ParseException { if(name.getLength()!=1) logger.warn("Unidentified AUEP Request parameter " + new String(data,name.getOffset(),name.getLength()) + " with value = " + new String(data,value.getOffset(),value.getLength())); else { switch(data[name.getOffset()]) { case StringFunctions.LOW_F_BYTE: case StringFunctions.HIGH_F_BYTE: command.setRequestedInfo(InfoCodeHandler.decodeList(data,value.getOffset(),value.getLength())); break; default: logger.warn("Unidentified AUEP Request parameter " + new String(data,name.getOffset(),name.getLength()) + " with value = " + new String(data,value.getOffset(),value.getLength())); break; } } }
@Override public JainMgcpCommandEvent decodeCommand(byte[] data,SplitDetails[] message) throws ParseException { command = new AuditEndpoint(source != null ? source : stack, endpoint); command.setTransactionHandle(remoteTID); try { (new CommandContentHandle()).parse(data,message); } catch (Exception e) { throw new ParseException(e.getMessage(), -1); } return command; }
/** * Receive notification of the parameter of a message. Parser will call * this method to report about parameter reading. * * @param name * the name of the parameter * @param value * the value of the parameter. */ public void param(byte[] data,SplitDetails name,SplitDetails value) throws ParseException { if(name.getLength()!=1) logger.warn("Unidentified AUEP Request parameter " + new String(data,name.getOffset(),name.getLength()) + " with value = " + new String(data,value.getOffset(),value.getLength())); else { switch(data[name.getOffset()]) { case StringFunctions.LOW_F_BYTE: case StringFunctions.HIGH_F_BYTE: command.setRequestedInfo(InfoCodeHandler.decodeList(data,value.getOffset(),value.getLength())); break; default: logger.warn("Unidentified AUEP Request parameter " + new String(data,name.getOffset(),name.getLength()) + " with value = " + new String(data,value.getOffset(),value.getLength())); break; } } }