Beispiel #1
0
void AmSipDispatcher::handleSipMsg(const string& dialog_id, AmSipReply &reply)
{
  const string& id = dialog_id.empty() ? reply.from_tag : dialog_id;
  AmSipReplyEvent* ev = new AmSipReplyEvent(reply);

  if(!AmEventDispatcher::instance()->post(id,ev)){
    if ((reply.code >= 100) && (reply.code < 300)) {
      if (AmConfig::UnhandledReplyLoglevel >= 0) {
	_LOG(AmConfig::UnhandledReplyLoglevel,
	     "unhandled SIP reply: %s\n", reply.print().c_str());
      }
    } else {
      WARN("unhandled SIP reply: %s\n", reply.print().c_str());
    }
    delete ev;
  }
}
void AmSipSubscription::onSipReply(const AmSipReply& reply, 
				   AmSipDialog::Status old_dlg_status)
{
  if ((seh!=NULL) && seh->onSipReply(reply, old_dlg_status))
    return;

  AmSipTransaction* sip_trans = dlg.getUACTrans(reply.cseq);
  if (!sip_trans) {
    WARN("No UAC transaction found for reply '%s', ignoring (%s)\n",
	 reply.print().c_str(), getDescription().c_str());
    return;
  }

  if (reply.code < 200) {
    DBG("Provisional reply received for subscription '%s'\n", getDescription().c_str());
    return;
  }

  if ((reply.code>=200)&&(reply.code<300)) {
      DBG("Positive reply to SUBSCRIBE\n");

      unsigned int expires_i = 0;
      string expires = getHeader(reply.hdrs, SIP_HDR_EXPIRES);
      if (expires.length()) {
	str2i(trim(expires, " \t"), expires_i);
      }

      AmSessionContainer::instance()->
	postEvent(sess_link,
		  new SIPSubscriptionEvent(SIPSubscriptionEvent::SubscribeActive,
					   req.from_tag, expires_i,
					   reply.code, reply.reason));
  } else if (reply.code >= 300) {
    DBG("Subscription '%s' failed\n", getDescription().c_str());
    if (sess_link.length()) {
      AmSessionContainer::instance()->
	postEvent(sess_link,
		  new SIPSubscriptionEvent(SIPSubscriptionEvent::SubscribeFailed,
					   req.from_tag, 0,
					   reply.code, reply.reason));
    }
    sub_state = SipSubStateTerminated;
  }
}