protected Int64 GetNewDelay(TSIP_Response response) { Int64 expires = mExpires; Int64 newdelay = expires; /* default value */ TSIP_Header hdr; int i; /*== NOTIFY with subscription-state header with expires parameter */ if (response.CSeq.RequestType == TSIP_Message.tsip_request_type_t.NOTIFY) { TSIP_HeaderSubscriptionState hdr_state = response.GetHeader(TSIP_Header.tsip_header_type_t.Subscription_State) as TSIP_HeaderSubscriptionState; if (hdr_state != null && hdr_state.Expires > 0) { expires = TSK_Time.Seconds2Milliseconds(hdr_state.Expires); goto compute; } } /*== Expires header */ if ((hdr = response.GetHeader(TSIP_Header.tsip_header_type_t.Expires)) != null) { expires = TSK_Time.Seconds2Milliseconds((hdr as TSIP_HeaderExpires).DeltaSeconds); goto compute; } /*== Contact header */ for (i = 0; (hdr = response.GetHeaderAtIndex(TSIP_Header.tsip_header_type_t.Contact, i)) != null; i++) { TSIP_HeaderContact contact = hdr as TSIP_HeaderContact; if (contact != null && contact.Uri != null) { String transport = TSK_Param.GetValueByName(contact.Uri.Params, "transport"); TSIP_Uri contactUri = this.Stack.GetContactUri(String.IsNullOrEmpty(transport) ? "udp" : transport); if (contactUri != null) { if (String.Equals(contact.Uri.UserName, contactUri.UserName) && String.Equals(contact.Uri.Host, contactUri.Host) && contact.Uri.Port == contactUri.Port) { if (contact.Expires >= 0) /* No expires parameter ==> -1*/ { expires = TSK_Time.Seconds2Milliseconds(contact.Expires); goto compute; } } } } } /* * 3GPP TS 24.229 - * * The UE shall reregister the public user identity either 600 seconds before the expiration time if the initial * registration was for greater than 1200 seconds, or when half of the time has expired if the initial registration * was for 1200 seconds or less. */ compute: expires = TSK_Time.Milliseconds2Seconds(expires); newdelay = (expires > 1200) ? (expires - 600) : (expires / 2); return(TSK_Time.Seconds2Milliseconds(newdelay)); }