private void send ( JainMgcpCommandEvent event ) { sent = true ; String host = "" ; int port = 0 ; switch ( event . getObjectIdentifier ( ) ) { case Constants . CMD_NOTIFY : Notify notifyCommand = ( Notify ) event ; NotifiedEntity notifiedEntity = notifyCommand . getNotifiedEntity ( ) ; if ( notifiedEntity == null ) { notifiedEntity = this . stack . provider . getNotifiedEntity ( ) ; } port = notifiedEntity . getPortNumber ( ) ; // if (notifiedEntity.getLocalName() != null) { // host = notifiedEntity.getLocalName() + "@"; // } host += notifiedEntity . getDomainName ( ) ; break ; case Constants . CMD_DELETE_CONNECTION : case Constants . CMD_RESTART_IN_PROGRESS : if ( remoteAddress != null ) { host = remoteAddress . getHostAddress ( ) ; port = remotePort ; break ; } default : // determite destination address and port to send request to // from endpoint identifier parameter. String domainName = event . getEndpointIdentifier ( ) . getDomainName ( ) ; // now checks does port number is specified in the domain name // if port number is not specified use 2427 by default int pos = domainName . indexOf ( ' ' ) ; if ( pos > 0 ) { port = Integer . parseInt ( domainName . substring ( pos + 1 ) ) ; host = domainName . substring ( 0 , pos ) ; } else { port = 2427 ; host = domainName ; } break ; } // construct the destination as InetAddress object InetAddress address = null ; try { address = InetAddress . getByName ( host ) ; } catch ( UnknownHostException e ) { throw new IllegalArgumentException ( "Unknown endpoint " + host ) ; } // save this tx in stack and start timer remoteTID = event . getTransactionHandle ( ) ; source = event . getSource ( ) ; event . setTransactionHandle ( localTID ) ; // encode event object as MGCP command and send over UDP. if ( originalPacket == null ) originalPacket = stack . allocatePacket ( ) ; originalPacket . setLength ( encode ( event , originalPacket . getRawData ( ) ) ) ; InetSocketAddress inetSocketAddress = new InetSocketAddress ( address , port ) ; originalPacket . setRemoteAddress ( inetSocketAddress ) ; resetReTransmissionTimer ( ) ; resetTHISTTimerTask ( false ) ; if ( logger . isDebugEnabled ( ) ) logger . debug ( "Send command event to " + address + "remote TX ID:" + remoteTID + ", message\n" + new String ( originalPacket . getRawData ( ) , 0 , originalPacket . getLength ( ) ) ) ; countOfCommandRetransmitted ++ ; stack . send ( originalPacket ) ; }
Sends MGCP command from the application to the endpoint specified in the message .