Esempio n. 1
0
static void
unsubscribe_by_nua(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...)
{
    struct message *subscribe, *response;
    struct event *event;

    nua_unsubscribe(nh, TAG_END());
    subscribe = s2_sip_wait_for_request(SIP_METHOD_SUBSCRIBE);

    s2_sip_respond_to(subscribe, dialog, SIP_200_OK, SIPTAG_EXPIRES_STR("0"), TAG_END());

    event = s2_wait_for_event(nua_r_unsubscribe, 200);
    fail_if(!event);
    fail_unless(s2_check_substate(event, nua_substate_active));
    s2_free_event(event);

    fail_if(s2_sip_request_to(dialog, SIP_METHOD_NOTIFY, NULL,
                              SIPTAG_EVENT(subscribe->sip->sip_event),
                              SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=timeout"),
                              SIPTAG_CONTENT_TYPE_STR(event_mime_type),
                              SIPTAG_PAYLOAD_STR(event_state),
                              TAG_END()));

    event = s2_wait_for_event(nua_i_notify, 200);
    fail_if(!event);
    fail_unless(s2_check_substate(event, nua_substate_terminated));
    s2_free_event(event);

    response = s2_sip_wait_for_response(200, SIP_METHOD_NOTIFY);
    fail_if(!response);
    s2_sip_free_message(response);
    s2_sip_free_message(subscribe);
}
Esempio n. 2
0
static int luasofia_nua_handle_unsubscribe(lua_State *L)
{
    /* get and check first argument (should be a luasofia_nua_handle_t) */
    luasofia_nua_handle_t *lnh = (luasofia_nua_handle_t*) luaL_checkudata(L, 1, NUA_HANDLE_MTABLE);
    if (lnh->nh) {
        su_home_t *home = su_home_create();
        /* get and check second argument (should be a tag table) */
        tagi_t *tags = luasofia_tags_table_to_taglist(L, 2, home);

        nua_unsubscribe(lnh->nh, TAG_NEXT(tags));
        su_home_unref(home);
    }
    return 0;
}