Changeset 212 for pjproject/trunk/pjsip/src/pjsip-simple/evsub.c
- Timestamp:
- Feb 21, 2006 11:47:00 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip-simple/evsub.c
r201 r212 198 198 pjsip_dialog *dlg; /**< Underlying dialog. */ 199 199 struct evpkg *pkg; /**< The event package. */ 200 unsigned option; /**< Options. */ 200 201 pjsip_evsub_user user; /**< Callback. */ 201 202 pjsip_role_e role; /**< UAC=subscriber, UAS=notifier */ … … 236 237 static const pj_str_t STR_TIMEOUT = { "timeout", 7}; 237 238 239 238 240 /* 239 241 * On unload module. … … 246 248 return PJ_SUCCESS; 247 249 } 250 251 /* Proto for pjsipsimple_strerror(). 252 * Defined in errno.c 253 */ 254 PJ_DECL(pj_str_t) pjsipsimple_strerror( pj_status_t statcode, 255 char *buf, pj_size_t bufsize ); 248 256 249 257 /* … … 257 265 { "NOTIFY", 6} 258 266 }; 267 268 pj_register_strerror(PJSIP_SIMPLE_ERRNO_START, PJ_ERRNO_SPACE_SIZE, 269 &pjsipsimple_strerror); 259 270 260 271 PJ_ASSERT_RETURN(endpt != NULL, PJ_EINVAL); … … 619 630 const pjsip_evsub_user *user_cb, 620 631 const pj_str_t *event, 632 unsigned option, 621 633 pjsip_evsub **p_evsub ) 622 634 { … … 641 653 sub->pkg = pkg; 642 654 sub->role = role; 655 sub->option = option; 643 656 sub->state = PJSIP_EVSUB_STATE_NULL; 644 657 sub->state_str = evsub_state_names[sub->state]; … … 698 711 const pjsip_evsub_user *user_cb, 699 712 const pj_str_t *event, 713 unsigned option, 700 714 pjsip_evsub **p_evsub) 701 715 { … … 706 720 707 721 pjsip_dlg_inc_lock(dlg); 708 status = evsub_create(dlg, PJSIP_UAC_ROLE, user_cb, event, &sub);722 status = evsub_create(dlg, PJSIP_UAC_ROLE, user_cb, event, option, &sub); 709 723 if (status != PJ_SUCCESS) 710 724 goto on_return; 711 725 712 /* Add unique Id to Event header */ 713 pj_create_unique_string(sub->pool, &sub->event->id_param); 726 /* Add unique Id to Event header, only when PJSIP_EVSUB_NO_EVENT_ID 727 * is not specified. 728 */ 729 if ((option & PJSIP_EVSUB_NO_EVENT_ID) == 0) { 730 pj_create_unique_string(sub->pool, &sub->event->id_param); 731 } 714 732 715 733 /* Increment dlg session. */ … … 731 749 const pjsip_evsub_user *user_cb, 732 750 pjsip_rx_data *rdata, 751 unsigned option, 733 752 pjsip_evsub **p_evsub) 734 753 { … … 758 777 PJ_ASSERT_RETURN(user_cb->on_rx_refresh, PJ_EINVALIDOP); 759 778 760 /* Request MUST have "Event" header: */ 761 779 /* Request MUST have "Event" header. We need the Event header to get 780 * the package name (don't want to add more arguments in the function). 781 */ 762 782 event_hdr = (pjsip_event_hdr*) 763 783 pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &STR_EVENT, NULL); … … 773 793 774 794 status = evsub_create(dlg, PJSIP_UAS_ROLE, user_cb, 775 &event_hdr->event_type, &sub);795 &event_hdr->event_type, option, &sub); 776 796 if (status != PJ_SUCCESS) 777 797 goto on_return; … … 1148 1168 } 1149 1169 1170 1150 1171 switch (event->body.tsx_state.type) { 1151 1172 case PJSIP_EVENT_RX_MSG: … … 1164 1185 1165 1186 if (!msg) { 1166 pj_assert(!"First transaction event is not TX or RX!"); 1187 //Note: 1188 // this transaction can be other transaction in the dialog. 1189 // The assertion below probably only valid for dialog that 1190 // only has one event subscription usage. 1191 //pj_assert(!"First transaction event is not TX or RX!"); 1167 1192 return NULL; 1168 1193 } … … 1188 1213 while (dlgsub != dlgsub_head) { 1189 1214 1190 /* Match event type and Id */ 1191 if (pj_strcmp(&dlgsub->sub->event->id_param, &event_hdr->id_param)==0 && 1192 pj_stricmp(&dlgsub->sub->event->event_type, &event_hdr->event_type)==0) 1215 if (pj_stricmp(&dlgsub->sub->event->event_type, 1216 &event_hdr->event_type)==0) 1193 1217 { 1194 break; 1195 } 1218 /* Event type matched. 1219 * Check if event ID matched too. 1220 */ 1221 if (pj_strcmp(&dlgsub->sub->event->id_param, 1222 &event_hdr->id_param)==0) 1223 { 1224 1225 break; 1226 1227 } 1228 /* 1229 * Otherwise if it is an UAC subscription, AND 1230 * PJSIP_EVSUB_NO_EVENT_ID flag is set, AND 1231 * the session's event id is NULL, AND 1232 * the incoming request is NOTIFY with event ID, then 1233 * we consider it as a match, and update the 1234 * session's event id. 1235 */ 1236 else if (dlgsub->sub->role == PJSIP_ROLE_UAC && 1237 (dlgsub->sub->option & PJSIP_EVSUB_NO_EVENT_ID)!=0 && 1238 dlgsub->sub->event->id_param.slen==0 && 1239 !pjsip_method_cmp(&tsx->method, &pjsip_notify_method)) 1240 { 1241 /* Update session's event id. */ 1242 pj_strdup(dlgsub->sub->pool, 1243 &dlgsub->sub->event->id_param, 1244 &event_hdr->id_param); 1245 1246 break; 1247 } 1248 } 1249 1250 1251 1196 1252 dlgsub = dlgsub->next; 1197 1253 } … … 1201 1257 PJ_LOG(4,(THIS_FILE, 1202 1258 "Subscription not found for %.*s, event=%.*s;id=%.*s", 1259 (int)tsx->method.name.slen, 1260 tsx->method.name.ptr, 1203 1261 (int)event_hdr->event_type.slen, 1204 1262 event_hdr->event_type.ptr, … … 1738 1796 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, NULL); 1739 1797 } 1740 } 1798 1799 } 1800 /* 1801 * Terminate event usage if we receive 481, 408, and 7 class 1802 * responses. 1803 */ 1804 if (sub->state != PJSIP_EVSUB_STATE_TERMINATED && 1805 (tsx->status_code==481 || tsx->status_code==408 || 1806 tsx->status_code/100 == 7)) 1807 { 1808 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, event); 1809 } 1741 1810 1742 1811 } else {
Note: See TracChangeset
for help on using the changeset viewer.