public String encode(JainMgcpResponseEvent event) { CreateConnectionResponse response = (CreateConnectionResponse) event; ReturnCode returnCode = response.getReturnCode(); StringBuffer s = new StringBuffer(); s.append(returnCode.getValue()).append(SINGLE_CHAR_SPACE).append(response.getTransactionHandle()).append( SINGLE_CHAR_SPACE).append(returnCode.getComment()).append(NEW_LINE); if (response.getConnectionIdentifier() != null) { s.append("I: ").append(response.getConnectionIdentifier()).append(NEW_LINE); } if (response.getSpecificEndpointIdentifier() != null) { s.append("Z: ").append(response.getSpecificEndpointIdentifier()).append(NEW_LINE); } if (response.getSecondConnectionIdentifier() != null) { s.append("I2: ").append(response.getSecondConnectionIdentifier()).append(NEW_LINE); } if (response.getSecondEndpointIdentifier() != null) { s.append("Z2: ").append(response.getSecondEndpointIdentifier()).append(NEW_LINE); } if (response.getLocalConnectionDescriptor() != null) { s.append(NEW_LINE).append(response.getLocalConnectionDescriptor()); } return s.toString(); }
@Override public JainMgcpResponseEvent getProvisionalResponse() { CreateConnectionResponse provisionalResponse = null; if (!sent) { ConnectionIdentifier connectionIdentifier = new ConnectionIdentifier("1"); provisionalResponse = new CreateConnectionResponse(source != null ? source : stack,ReturnCode.Transaction_Being_Executed, connectionIdentifier); provisionalResponse.setTransactionHandle(remoteTID); } return provisionalResponse; } }
/** * Receive notification of the session description. Parser will call * this method to report about session descriptor reading. * * @param sd * the session description from message. */ public void sessionDescription(String sd) throws ParseException { response.setLocalConnectionDescriptor(new ConnectionDescriptor(sd)); } }
@Override public void execute(final Object message) throws Exception { final CreateConnectionResponse response = (CreateConnectionResponse) message; if (connId == null) { connId = response.getConnectionIdentifier(); } localDesc = response.getLocalConnectionDescriptor(); // If the end point ends with a wild card we should update it. if (endpointId.getLocalEndpointName().endsWith("$")) { endpointId = response.getSpecificEndpointIdentifier(); endpoint.tell(new UpdateEndpointId(endpointId), source); } } }
public void processMgcpResponseEvent(JainMgcpResponseEvent evt) { CreateConnectionResponse resp = (CreateConnectionResponse) evt; switch (resp.getReturnCode().getValue()) { case ReturnCode.TRANSACTION_BEING_EXECUTED : return; case ReturnCode.TRANSACTION_EXECUTED_NORMALLY : connection.connectionID = resp.getConnectionIdentifier(); connection.setConcreteName(resp.getSpecificEndpointIdentifier()); connection.sdpPortManager.setLocalDescriptor(resp.getLocalConnectionDescriptor().toString()); } catch (Exception e) { e.printStackTrace(); connection.errorMsg = resp.getReturnCode().getComment();
public void processMgcpResponseEvent(JainMgcpResponseEvent evt) { CreateConnectionResponse resp = (CreateConnectionResponse) evt; switch (resp.getReturnCode().getValue()) { case ReturnCode.TRANSACTION_BEING_EXECUTED: return; case ReturnCode.TRANSACTION_EXECUTED_NORMALLY: containers[0].setConcreteName(resp.getSpecificEndpointIdentifier()); containers[1].setConcreteName(resp.getSecondEndpointIdentifier()); connections[0] = resp.getConnectionIdentifier(); connections[1] = resp.getSecondConnectionIdentifier(); try { signal("success"); } catch (Exception e) { } break; default: try { signal("failure"); } catch (Exception e) { } } }
log.info("Receive CRCX response: " + event); ReturnCode status = event.getReturnCode(); break; default: ReturnCode rc = event.getReturnCode(); log.severe("CRCX failed. Value = " + rc.getValue() + " Comment = " + rc.getComment()); + event.getReturnCode(), Response.SERVER_INTERNAL_ERROR); if (event.getSecondEndpointIdentifier() == null) { response = getMessageFactory().createResponse(Response.OK, request, contentType, event.getLocalConnectionDescriptor().toString().getBytes()); } catch (ParseException ex) { IVR_ENDPOINT_NAME, mmsBindAddress + ":" + MGCP_PEER_PORT); CreateConnection createConnection = new CreateConnection(this, getCallIdentifier(), event .getSpecificEndpointIdentifier(), ConnectionMode.Confrnce); if(startMailMedia) eid = event.getSecondEndpointIdentifier(); }else eid = event.getSpecificEndpointIdentifier();
ConnectionIdentifier connId = new ConnectionIdentifier(buffer.toString()); final ReturnCode code = ReturnCode.Transaction_Executed_Normally; final CreateConnectionResponse response = new CreateConnectionResponse(self, code, connId); endpointId = new EndpointIdentifier(buffer.toString(), domain); response.setSpecificEndpointIdentifier(endpointId); buffer.append(connectionIdPool.get()); connId = new ConnectionIdentifier(buffer.toString()); response.setSecondConnectionIdentifier(connId); endpointName = secondaryEndpointId.getLocalEndpointName(); if (endpointName.endsWith("$")) { secondaryEndpointId = new EndpointIdentifier(buffer.toString(), domain); response.setSecondEndpointIdentifier(secondaryEndpointId); response.setLocalConnectionDescriptor(descriptor); final int transaction = crcx.getTransactionHandle(); response.setTransactionHandle(transaction); System.out.println(response.toString()); sender.tell(response, self);
CreateConnectionResponse ccResponse = (CreateConnectionResponse) event; int responseCode = ccResponse.getReturnCode().getValue(); MgcpResponseType type = MgcpResponseType.getResponseTypeFromCode(responseCode); EndpointIdentifier specificEndpointId = ccResponse.getSpecificEndpointIdentifier(); if (specificEndpointId != null && this.endpointId.compareTo(specificEndpointId.toString()) == 0) { this.connectionIds.add(ccResponse.getConnectionIdentifier());
/** * Receive notification of the parameter of a message. Parser will call * this method to report about parameter reading. * * @param name * the name of the paremeter * @param value * the value of the parameter. */ public void param(String name, String value) throws ParseException { if (name.equalsIgnoreCase("I")) { response.setConnectionIdentifier(new ConnectionIdentifier(value)); } else if (name.equalsIgnoreCase("I2")) { response.setSecondConnectionIdentifier(new ConnectionIdentifier(value)); } else if (name.equalsIgnoreCase("Z")) { response.setSpecificEndpointIdentifier(utils.decodeEndpointIdentifier(value)); } else if (name.equalsIgnoreCase("Z2")) { response.setSecondEndpointIdentifier(utils.decodeEndpointIdentifier(value)); } }
@Override public void execute(final Object message) throws Exception { /* Stop the timer. */ final UntypedActorContext context = getContext(); context.setReceiveTimeout(Duration.Undefined()); if (remoteDesc != null && remoteDesc.toString().contains("PleaseFailThisConnection")) { final CreateConnectionResponse response = (CreateConnectionResponse) message; if (connId == null) { connId = response.getConnectionIdentifier(); } fsm.transition(message, closing); return; } // Handle results from opening or modifying states. final Class<?> klass = message.getClass(); if (CreateConnectionResponse.class.equals(klass)) { super.execute(message); } else if (ModifyConnectionResponse.class.equals(klass)) { final ModifyConnectionResponse response = (ModifyConnectionResponse) message; localDesc = response.getLocalConnectionDescriptor(); } final ConnectionStateChanged event = new ConnectionStateChanged(localDesc, ConnectionStateChanged.State.OPEN, connId); for (final ActorRef observer : observers) { observer.tell(event, source); } // Log the state change. log(ConnectionStateChanged.State.OPEN); } }
break; case Constants.CMD_CREATE_CONNECTION: response = new CreateConnectionResponse(this, ReturnCode.Transient_Error, new ConnectionIdentifier(Long .toHexString(new Random(System.currentTimeMillis()).nextLong()))); break;
public void processMgcpResponseEvent(JainMgcpResponseEvent evt) { CreateConnectionResponse resp = (CreateConnectionResponse) evt; switch (resp.getReturnCode().getValue()) { case ReturnCode.TRANSACTION_BEING_EXECUTED : return; case ReturnCode.TRANSACTION_EXECUTED_NORMALLY : connection.connectionID = resp.getConnectionIdentifier(); connection.setConcreteName(resp.getSpecificEndpointIdentifier()); connection.sdpPortManager.setLocalDescriptor(resp.getLocalConnectionDescriptor().toString()); } catch (Exception e) { e.printStackTrace(); connection.errorMsg = resp.getReturnCode().getComment();
public void processMgcpResponseEvent(JainMgcpResponseEvent evt) { CreateConnectionResponse resp = (CreateConnectionResponse) evt; switch (resp.getReturnCode().getValue()) { case ReturnCode.TRANSACTION_BEING_EXECUTED: return; case ReturnCode.TRANSACTION_EXECUTED_NORMALLY: containers[0].setConcreteName(resp.getSpecificEndpointIdentifier()); containers[1].setConcreteName(resp.getSecondEndpointIdentifier()); connections[0] = resp.getConnectionIdentifier(); connections[1] = resp.getSecondConnectionIdentifier(); try { signal("success"); } catch (Exception e) { } break; default: try { signal("failure"); } catch (Exception e) { } } }
@Override public void execute(final Object message) throws Exception { final CreateConnectionResponse response = (CreateConnectionResponse) message; if (connId == null) { connId = response.getConnectionIdentifier(); } localDesc = response.getLocalConnectionDescriptor(); // If the end point ends with a wild card we should update it. if (endpointId.getLocalEndpointName().endsWith("$")) { endpointId = response.getSpecificEndpointIdentifier(); endpoint.tell(new UpdateEndpointId(endpointId), source); } } }
ConnectionIdentifier connId = new ConnectionIdentifier(buffer.toString()); final ReturnCode code = ReturnCode.Transaction_Executed_Normally; final CreateConnectionResponse response = new CreateConnectionResponse(self, code, connId); response.setSpecificEndpointIdentifier(endpointId); buffer.append(connectionIdPool.get()); ConnectionIdentifier secondayConnId = new ConnectionIdentifier(buffer.toString()); response.setSecondConnectionIdentifier(secondayConnId); endpointName = secondaryEndpointId.getLocalEndpointName(); if (endpointName.endsWith("$")) { response.setSecondEndpointIdentifier(secondaryEndpointId); response.setLocalConnectionDescriptor(descriptor); final int transaction = crcx.getTransactionHandle(); response.setTransactionHandle(transaction); System.out.println(response.toString()); sender.tell(response, self);
response.setConnectionIdentifier(new ConnectionIdentifier(new String(data,value.getOffset(),value.getLength()))); break; case StringFunctions.LOW_Z_BYTE: case StringFunctions.HIGH_Z_BYTE: response.setSpecificEndpointIdentifier(EndpointIdentifierHandler.decode(data,value.getOffset(),value.getLength())); break; default: case StringFunctions.HIGH_I_BYTE: if(data[name.getOffset()+1]==StringFunctions.TWO_BYTE) response.setSecondConnectionIdentifier(new ConnectionIdentifier(new String(data,value.getOffset(),value.getLength()))); break; case StringFunctions.LOW_Z_BYTE: case StringFunctions.HIGH_Z_BYTE: if(data[name.getOffset()+1]==StringFunctions.TWO_BYTE) response.setSecondEndpointIdentifier(EndpointIdentifierHandler.decode(data,value.getOffset(),value.getLength())); break; default:
@Override protected void createConnection (final Object message, final ActorRef sender) { final jain.protocol.ip.mgcp.message.CreateConnection crcx = (jain.protocol.ip.mgcp.message.CreateConnection) message; if(logger.isInfoEnabled()) logger.info("createConnection: " +crcx.toString()); // check if its a conference and call link request if(crcx.getSecondEndpointIdentifier() != null && crcx.getSecondEndpointIdentifier().getLocalEndpointName() != null && crcx.getSecondEndpointIdentifier().getLocalEndpointName().contains("cnf")){ // if yes then fail this connection request if(logger.isInfoEnabled()) logger.info("got conference and call link request, will fail it! with error code Endpoint_Unknown"); StringBuilder buffer = new StringBuilder(); buffer.append(connectionIdPool.get()); ConnectionIdentifier connId = new ConnectionIdentifier(buffer.toString()); sender.tell(new CreateConnectionResponse(self(), ReturnCode.Endpoint_Unknown, connId), self()); }else { // if not then let daddy proceed with existing mocked mechanism. super.createConnection(message, sender); } } }
ReturnCode returnCode = response.getReturnCode(); totalLength+=StringFunctions.encodeInt(array,totalLength,response.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; byte[] commentBytes=returnCode.getComment().getBytes(); if (response.getConnectionIdentifier() != null) byte[] connectionIdentifierBytes=response.getConnectionIdentifier().toString().getBytes(); System.arraycopy(connectionIdentifierBytes, 0, array,totalLength, connectionIdentifierBytes.length); totalLength+=connectionIdentifierBytes.length; if (response.getSpecificEndpointIdentifier() != null) totalLength+=EndpointIdentifierHandler.encode(array,totalLength,response.getSpecificEndpointIdentifier()); if (response.getSecondConnectionIdentifier() != null) byte[] connectionIdentifierBytes=response.getSecondConnectionIdentifier().toString().getBytes(); System.arraycopy(connectionIdentifierBytes, 0, array,totalLength, connectionIdentifierBytes.length); totalLength+=connectionIdentifierBytes.length; if (response.getSecondEndpointIdentifier() != null) totalLength+=EndpointIdentifierHandler.encode(array,totalLength,response.getSecondEndpointIdentifier()); if (response.getLocalConnectionDescriptor() != null) byte[] rcdBytes=response.getLocalConnectionDescriptor().toString().getBytes();
public void onCreateConnectionResponse(CreateConnectionResponse event, ActivityContextInterface aci) { logger.info("Receive CRCX response: " + event.getTransactionHandle()); ReturnCode status = event.getReturnCode(); this.setEndpointName(event.getSpecificEndpointIdentifier().getLocalEndpointName()); this.setConnectionIdentifier(event.getConnectionIdentifier().toString()); String sdp = event.getLocalConnectionDescriptor().toString();