public String encode(JainMgcpResponseEvent event) { ModifyConnectionResponse response = (ModifyConnectionResponse) 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.getLocalConnectionDescriptor() != null) { s.append(NEW_LINE).append(response.getLocalConnectionDescriptor()); } return s.toString(); }
/** * 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 { String[] tokens = utils.splitStringBySpace(header); int tid = Integer.parseInt(tokens[1]); response = new ModifyConnectionResponse(source != null ? source : stack, utils.decodeReturnCode(Integer .parseInt(tokens[0]))); response.setTransactionHandle(tid); }
/** * 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)); } }
final ModifyConnectionResponse response = new ModifyConnectionResponse(self, code); final int transaction = mdcx.getTransactionHandle(); response.setTransactionHandle(transaction); System.out.println(response.toString()); sender.tell(response, self); } else { code = ReturnCode.Transaction_Executed_Normally; final ModifyConnectionResponse response = new ModifyConnectionResponse(self, code); final ConnectionDescriptor descriptor = new ConnectionDescriptor(sdp); response.setLocalConnectionDescriptor(descriptor); final int transaction = mdcx.getTransactionHandle(); response.setTransactionHandle(transaction); System.out.println(response.toString()); sender.tell(response, self);
public void processMgcpResponseEvent(JainMgcpResponseEvent evt) { ModifyConnectionResponse resp = (ModifyConnectionResponse) evt; switch (resp.getReturnCode().getValue()) { case ReturnCode.TRANSACTION_BEING_EXECUTED: return; case ReturnCode.TRANSACTION_EXECUTED_NORMALLY: try { connection.sdpPortManager.setLocalDescriptor(resp.getLocalConnectionDescriptor().toString()); connection.fsm.signal(ConnectionTransition.OPENED); } catch (UnknownTransitionException e) { } catch (Exception e) { e.printStackTrace(); connection.fsm.signalAsync(ConnectionTransition.FAILURE); } break; case ReturnCode.ENDPOINT_UNKNOWN : break; case ReturnCode.CONNECTION_WAS_DELETED: break; default: break; } } }
private void open(final ModifyConnectionResponse response) { localDescriptor = response.getLocalConnectionDescriptor(); fireModified(); }
@Override public JainMgcpResponseEvent getProvisionalResponse() { ModifyConnectionResponse provisionalresponse = null; if (!sent) provisionalresponse = new ModifyConnectionResponse(source != null ? source : stack,ReturnCode.Transaction_Being_Executed); return provisionalresponse; } }
public void processMgcpResponseEvent(JainMgcpResponseEvent evt) { ModifyConnectionResponse resp = (ModifyConnectionResponse) evt; switch (resp.getReturnCode().getValue()) { case ReturnCode.TRANSACTION_BEING_EXECUTED: return; case ReturnCode.TRANSACTION_EXECUTED_NORMALLY: try { signal("success"); } catch (UnknownTransitionException e) { } break; default: try { signal("failure"); } catch (UnknownTransitionException e) { } break; } } }
final ModifyConnectionResponse response = new ModifyConnectionResponse(self, code); final int transaction = mdcx.getTransactionHandle(); response.setTransactionHandle(transaction); System.out.println(response.toString()); sender.tell(response, self); } else { code = ReturnCode.Transaction_Executed_Normally; final ModifyConnectionResponse response = new ModifyConnectionResponse(self, code); final ConnectionDescriptor descriptor = new ConnectionDescriptor(sdp); response.setLocalConnectionDescriptor(descriptor); final int transaction = mdcx.getTransactionHandle(); response.setTransactionHandle(transaction); System.out.println(response.toString()); sender.tell(response, self);
public void processMgcpResponseEvent(JainMgcpResponseEvent evt) { ModifyConnectionResponse resp = (ModifyConnectionResponse) evt; switch (resp.getReturnCode().getValue()) { case ReturnCode.TRANSACTION_BEING_EXECUTED: return; case ReturnCode.TRANSACTION_EXECUTED_NORMALLY: try { connection.sdpPortManager.setLocalDescriptor(resp.getLocalConnectionDescriptor().toString()); connection.fsm.signal(ConnectionTransition.OPENED); } catch (UnknownTransitionException e) { } catch (Exception e) { e.printStackTrace(); connection.fsm.signalAsync(ConnectionTransition.FAILURE); } break; case ReturnCode.ENDPOINT_UNKNOWN : break; case ReturnCode.CONNECTION_WAS_DELETED: break; default: break; } } }
private void halfOpen(final ModifyConnectionResponse response) { localDescriptor = response.getLocalConnectionDescriptor(); setState(OPEN); fireOpen(); }
@Override public JainMgcpResponseEvent getProvisionalResponse() { ModifyConnectionResponse provisionalresponse = null; if (!sent) provisionalresponse = new ModifyConnectionResponse(source != null ? source : stack,ReturnCode.Transaction_Being_Executed); return provisionalresponse; } }
public void processMgcpResponseEvent(JainMgcpResponseEvent evt) { ModifyConnectionResponse resp = (ModifyConnectionResponse) evt; switch (resp.getReturnCode().getValue()) { case ReturnCode.TRANSACTION_BEING_EXECUTED: return; case ReturnCode.TRANSACTION_EXECUTED_NORMALLY: try { signal("success"); } catch (UnknownTransitionException e) { } break; default: try { signal("failure"); } catch (UnknownTransitionException e) { } break; } } }
public int encode(JainMgcpResponseEvent event,byte[] array) { ModifyConnectionResponse response = (ModifyConnectionResponse) event; ReturnCode returnCode = response.getReturnCode(); int totalLength=ReturnCodeHandler.encode(array,0,returnCode); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=StringFunctions.encodeInt(array,totalLength,response.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; byte[] commentBytes=returnCode.getComment().getBytes(); System.arraycopy(commentBytes, 0, array,totalLength, commentBytes.length); totalLength+=commentBytes.length; array[totalLength++]=StringFunctions.NEWLINE_BYTE; if (response.getLocalConnectionDescriptor() != null) { array[totalLength++]=StringFunctions.NEWLINE_BYTE; byte[] rcdBytes=response.getLocalConnectionDescriptor().toString().getBytes(); System.arraycopy(rcdBytes, 0, array,totalLength, rcdBytes.length); totalLength+=rcdBytes.length; array[totalLength++]=StringFunctions.NEWLINE_BYTE; } return totalLength; }
@Override public void execute(final Object message) throws Exception { /* Stop the timer. */ final UntypedActorContext context = getContext(); context.setReceiveTimeout(Duration.Undefined()); // 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); } }
public JainMgcpResponseEvent decodeResponse(byte[] data,SplitDetails[] msg,Integer txID,ReturnCode returnCode) throws ParseException { response = new ModifyConnectionResponse(source != null ? source : stack, returnCode); response.setTransactionHandle(txID); try { (new ResponseContentHandle()).parse(data,msg); } catch (IOException e) { logger.error("Decoding of MDCX Response failed", e); } return response; }
@Override public JainMgcpResponseEvent getProvisionalResponse() { ModifyConnectionResponse provisionalresponse = null; if (!sent) { provisionalresponse = new ModifyConnectionResponse(source != null ? source : stack, ReturnCode.Transaction_Being_Executed); } return provisionalresponse; }
int responseCode = mcResponse.getReturnCode().getValue(); MgcpResponseType type = MgcpResponseType.getResponseTypeFromCode(responseCode);
/** * 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)); } }
public int encode(JainMgcpResponseEvent event,byte[] array) { ModifyConnectionResponse response = (ModifyConnectionResponse) event; ReturnCode returnCode = response.getReturnCode(); int totalLength=ReturnCodeHandler.encode(array,0,returnCode); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=StringFunctions.encodeInt(array,totalLength,response.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; byte[] commentBytes=returnCode.getComment().getBytes(); System.arraycopy(commentBytes, 0, array,totalLength, commentBytes.length); totalLength+=commentBytes.length; array[totalLength++]=StringFunctions.NEWLINE_BYTE; if (response.getLocalConnectionDescriptor() != null) { array[totalLength++]=StringFunctions.NEWLINE_BYTE; byte[] rcdBytes=response.getLocalConnectionDescriptor().toString().getBytes(); System.arraycopy(rcdBytes, 0, array,totalLength, rcdBytes.length); totalLength+=rcdBytes.length; array[totalLength++]=StringFunctions.NEWLINE_BYTE; } return totalLength; }