Ejemplo n.º 1
0
static void send_register_cb(void* token, pjsip_event *event)
{
    ThirdPartyRegData* tsxdata = (ThirdPartyRegData*)token;
    pjsip_transaction* tsx = event->body.tsx_state.tsx;

    if ((tsxdata->default_handling == SESSION_TERMINATED) &&
            ((tsx->status_code == 408) ||
             (PJSIP_IS_STATUS_IN_CLASS(tsx->status_code, 500))))
    {
        std::string error_msg = "Third-party REGISTER transaction failed with code " + std::to_string(tsx->status_code);
        TRC_INFO(error_msg.c_str());

        SAS::Event event(tsxdata->trail, SASEvent::REGISTER_AS_FAILED, 0);
        event.add_var_param(error_msg);
        SAS::report_event(event);

        third_party_register_failed(tsxdata->public_id, tsxdata->trail);
    }

    // printf("Expiry: %d, Is_initial_registration: %d\n", tsxdata->expires, tsxdata->is_initial_registration);
    if (tsx->status_code == 200)
    {
        if (tsxdata->expires == 0)
        {
            third_party_reg_stats_tables->de_reg_tbl->increment_successes();
        }
        else if (tsxdata->is_initial_registration)
        {
            third_party_reg_stats_tables->init_reg_tbl->increment_successes();
        }
        else
        {
            third_party_reg_stats_tables->re_reg_tbl->increment_successes();
        }
    }
    else
        // Count all failed registration attempts, not just ones that result in user
        // being unsubscribed.
    {
        if (tsxdata->expires == 0)
        {
            third_party_reg_stats_tables->de_reg_tbl->increment_failures();
        }
        else if (tsxdata->is_initial_registration)
        {
            third_party_reg_stats_tables->init_reg_tbl->increment_failures();
        }
        else
        {
            third_party_reg_stats_tables->re_reg_tbl->increment_failures();
        }
    }

    delete tsxdata;
    tsxdata = NULL;
}
Ejemplo n.º 2
0
static void send_register_cb(void* token, pjsip_event *event)
{
  ThirdPartyRegData* tsxdata = (ThirdPartyRegData*)token;
  pjsip_transaction* tsx = event->body.tsx_state.tsx;

  if ((tsxdata->default_handling == SESSION_TERMINATED) &&
      ((tsx->status_code == 408) ||
       (PJSIP_IS_STATUS_IN_CLASS(tsx->status_code, 500))))
  {
    std::string error_msg = "Third-party REGISTER transaction failed with code " + std::to_string(tsx->status_code);
    LOG_INFO(error_msg.c_str());

    SAS::Event event(tsxdata->trail, SASEvent::REGISTER_AS_FAILED, 0);
    event.add_var_param(error_msg);
    SAS::report_event(event);

    third_party_register_failed(tsxdata->public_id, tsxdata->trail);
  }
  delete tsxdata;
}