/**
   * Handles server noninvite message
   *
   * @param msg - noninvite message
   */
  public void handleIncomingBye(final Request msg) {

    assert TransactionUtils.isTransactionExecutionThread()
        : "Code run in wrong thread. Must be run in TransactionThread. Now in "
            + Thread.currentThread();
    assert !done.get();
    assert msg != null && MessageType.SIP_BYE == MessageType.parse(msg.getMethod());

    Logger.log("Remote party has sent noninvite");
    if (!done.get()) {

      final Dialog dialog = getStackContext().getDialogStorage().findDialogForMessage(msg);
      assert dialog != null;
      assert STATED == dialog.getState();

      dialog.getMessageHistory().addMessage(msg, true);

      final TransactionManager transactionManager = getTransactionManager();
      transactionManager.addListener(
          new FirstMessageResolver(SIP_BYE_SERVER.getName(), dialog, msg, transactionManager));

      final Transaction transaction =
          transactionManager.lookUpTransaction(dialog, null, SIP_BYE_SERVER);
      runAsynchronously(transaction, TRANSACTION_TIMEOUT);
    }
  }
  private void doHandleIncomingUpdate(
      Request msg,
      Dialog dialog,
      TransactionType<UpdateSrvTransaction, UpdateServerTransaction> transactionType) {

    dialog.getMessageHistory().addMessage(msg, true);
    SdpMessage sdp = SipMessageUtils.getSdpFromMessage(msg);
    if (sdp != null) {
      dialog.setIncomingSdpMessage(sdp);
    }

    final TransactionManager transactionManager = getTransactionManager();
    transactionManager.addListener(
        new FirstMessageResolver(transactionType.getName(), dialog, msg, transactionManager));

    final UpdateSrvTransaction transaction =
        transactionManager.lookUpTransaction(dialog, null, transactionType);
    runAsynchronously((Transaction<Boolean, BaseSipMessage>) transaction);
  }
  private void doHandleIncomingInvite(
      final Request msg,
      final Dialog dialog,
      final TransactionType<InviteSrvTransaction, ? extends ServerCommonInviteTransaction>
          transactionType) {

    dialog.getMessageHistory().addMessage(msg, true);
    // DIALOG.putCustomParameter(ParamKey.LAST_MESSAGE, msg);
    Logger.log("doHandleIncomingInvite", "");
    SdpMessage sdp = SipMessageUtils.getSdpFromMessage(msg);
    if (sdp != null) {
      dialog.setIncomingSdpMessage(sdp);
    }

    final TransactionManager transactionManager = getTransactionManager();
    transactionManager.addListener(
        new FirstMessageResolver(transactionType.getName(), dialog, msg, transactionManager));

    final InviteSrvTransaction transaction =
        transactionManager.lookUpTransaction(dialog, null, transactionType);
    runAsynchronously((Transaction<Boolean, BaseSipMessage>) transaction);
  }