/// <summary> /// Any -> (shutdown) -> InProgress /// </summary> /// <param name="parameters"></param> /// <returns></returns> private Boolean Any_2_InProgress_X_shutdown(params Object[] parameters) { /* schedule shutdow timeout */ this.TimerShutdown.Start(); /* alert user */ TSIP_EventDialog.Signal(TSIP_EventDialog.tsip_dialog_event_type_t.Terminating, base.SipSession, "Terminating dialog", null); mUnRegsitering = true; return(this.SendRegister(true)); }
//-------------------------------------------------------- // == STATE MACHINE BEGIN == //-------------------------------------------------------- /// <summary> /// Any -> (hangup) -> InProgress /// </summary> /// <param name="parameters"></param> /// <returns></returns> private Boolean Any_2_InProgress_X_hangup(params Object[] parameters) { /* Set current action */ base.CurrentAction = parameters[2] as TSIP_Action; /* Alert the user */ TSIP_EventDialog.Signal(TSIP_EventDialog.tsip_dialog_event_type_t.Terminating, base.SipSession, "Terminating dialog", null); mUnRegsitering = true; return(this.SendRegister(true)); }
/// <summary> /// InProgress -> (cancel) -> Terminated /// </summary> /// <param name="parameters"></param> /// <returns></returns> private Boolean InProgress_2_Terminated_X_cancel(params Object[] parameters) { /* Cancel all transactions associated to this dialog (will also be done when the dialog is destroyed (worth nothing)) */ if (!base.Stack.LayerTransac.CancelTransactionByDialogId(base.Id)) { return(false); } /* alert the user */ TSIP_EventDialog.Signal(TSIP_EventDialog.tsip_dialog_event_type_t.RequestCancelled, base.SipSession, "Registration cancelled", null); return(true); }
/// <summary> /// Any -> (error) -> Terminated /// </summary> /// <param name="parameters"></param> /// <returns></returns> private Boolean Any_2_Terminated_X_Error(params Object[] parameters) { TSIP_Response response = parameters[2] as TSIP_Response; if (response != null) { base.SetLastError((short)response.StatusCode, response.ReasonPhrase, response); TSIP_EventRegister.Signal(mUnRegsitering ? TSIP_EventRegister.tsip_register_event_type_t.AO_UNREGISTER : TSIP_EventRegister.tsip_register_event_type_t.AO_REGISTER, base.SipSession, response.StatusCode, response.ReasonPhrase, response); } else { TSIP_EventDialog.Signal(TSIP_EventDialog.tsip_dialog_event_type_t.GlobalError, base.SipSession, "Global error", null); } return(false); }
private Boolean OnTerminated() { TSK_Debug.Info("=== REGISTER Dialog terminated ==="); /* Cleanup IPSec SAs */ //if (TSIP_DIALOG_GET_STACK(self)->security.secagree_mech && tsk_striequals(TSIP_DIALOG_GET_STACK(self)->security.secagree_mech, "ipsec-3gpp")) //{ // tsip_transport_cleanupSAs(TSIP_DIALOG_GET_STACK(self)->layer_transport); //} /* alert the user */ TSIP_EventDialog.Signal(TSIP_EventDialog.tsip_dialog_event_type_t.Terminated, base.SipSession, String.IsNullOrEmpty(base.LastErrorPhrase) ? "Dialog terminated" : base.LastErrorPhrase, base.LastErrorMessage); /* Remove from the dialog layer. */ base.RemoveFromLayer(); return(true); }
/// <summary> /// Any -> (transport error) -> Terminated /// </summary> /// <param name="parameters"></param> /// <returns></returns> private Boolean Any_2_Terminated_X_transportError(params Object[] parameters) { TSIP_EventDialog.Signal(TSIP_EventDialog.tsip_dialog_event_type_t.TransportError, base.SipSession, "Transport error", null); return(true); }
/// <summary> /// InProgress -> (2xx) -> Connected /// </summary> /// <param name="parameters"></param> /// <returns></returns> private Boolean InProgress_2_Connected_X_2xx(params Object[] parameters) { Boolean ret = true; TSIP_Response response = parameters[1] as TSIP_Response; Boolean first_time_to_connect = base.State == tsip_dialog_state_t.Initial; /* - Set P-associated-uriS * - Update service-routes * - Update Pats */ { int index; // const tsip_header_Path_t *hdr_Path; // const tsip_header_Service_Route_t *hdr_Service_Route; // const tsip_header_P_Associated_URI_t *hdr_P_Associated_URI_t; TSIP_Uri uri; /* To avoid memory leaks ==> delete all concerned objects (it worth nothing) */ //TSK_OBJECT_SAFE_FREE(TSIP_DIALOG_GET_STACK(self)->associated_uris); //TSK_OBJECT_SAFE_FREE(TSIP_DIALOG_GET_STACK(self)->service_routes); //TSK_OBJECT_SAFE_FREE(TSIP_DIALOG_GET_STACK(self)->paths); /* Associated URIs */ /*for(index = 0; (hdr_P_Associated_URI_t = (const tsip_header_P_Associated_URI_t*)tsip_message_get_headerAt(response, tsip_htype_P_Associated_URI, index)); index++){ * if(!TSIP_DIALOG_GET_STACK(self)->associated_uris){ * TSIP_DIALOG_GET_STACK(self)->associated_uris = tsk_list_create(); * } * uri = tsk_object_ref(hdr_P_Associated_URI_t->uri); * tsk_list_push_back_data(TSIP_DIALOG_GET_STACK(self)->associated_uris, (void**)&uri); * }*/ /* Service-Route (3GPP TS 24.229) * store the list of service route values contained in the Service-Route header field and bind the list to the contact * address used in registration, in order to build a proper preloaded Route header field value for new dialogs and * standalone transactions when using the respective contact address. */ /*for(index = 0; (hdr_Service_Route = (const tsip_header_Service_Route_t*)tsip_message_get_headerAt(response, tsip_htype_Service_Route, index)); index++){ * if(!TSIP_DIALOG_GET_STACK(self)->service_routes){ * TSIP_DIALOG_GET_STACK(self)->service_routes = tsk_list_create(); * } * uri = tsk_object_ref(hdr_Service_Route->uri); * tsk_list_push_back_data(TSIP_DIALOG_GET_STACK(self)->service_routes, (void**)&uri); * }*/ /* Paths */ /*for(index = 0; (hdr_Path = (const tsip_header_Path_t*)tsip_message_get_headerAt(response, tsip_htype_Path, index)); index++){ * if(TSIP_DIALOG_GET_STACK(self)->paths == 0){ * TSIP_DIALOG_GET_STACK(self)->paths = tsk_list_create(); * } * uri = tsk_object_ref(hdr_Path->uri); * tsk_list_push_back_data(TSIP_DIALOG_GET_STACK(self)->paths, (void**)&uri); * }*/ } /* 3GPP TS 24.229 - 5.1.1.2 Initial registration */ if (first_time_to_connect) { Boolean barred = true; //const tsk_list_item_t *item; //const tsip_uri_t *uri; //const tsip_uri_t *uri_first = 0; /* * b) store as the default public user identity the first URI on the list of URIs present in the P-Associated-URI header * field and bind it to the respective contact address of the UE and the associated set of security associations or TLS * session; * NOTE 4: When using the respective contact address and associated set of security associations or TLS session, the * UE can utilize additional URIs contained in the P-Associated-URI header field and bound it to the * respective contact address of the UE and the associated set of security associations or TLS session, e.g. for * application purposes. * c) treat the identity under registration as a barred public user identity, if it is not included in the P-Associated-URI * header field; */ //tsk_list_foreach(item, TSIP_DIALOG_GET_STACK(self)->associated_uris){ // uri = item->data; // if(item == TSIP_DIALOG_GET_STACK(self)->associated_uris->head){ // uri_first = item->data; // } // if(!tsk_object_cmp(TSIP_DIALOG_GET_STACK(self)->identity.preferred, uri)){ // barred = 0; // break; // } //} //if(barred && uri_first){ // TSK_OBJECT_SAFE_FREE(TSIP_DIALOG_GET_STACK(self)->identity.preferred); // TSIP_DIALOG_GET_STACK(self)->identity.preferred = tsk_object_ref((void*)uri_first); //} } /* Update the dialog state */ if (!(ret = this.UpdateWithResponse(response))) { return(ret); } /* Reset current action */ base.CurrentAction = null; /* Request timeout for dialog refresh (re-registration). */ this.TimerRefresh.Period = (UInt64)base.GetNewDelay(response); this.TimerRefresh.Start(); /* Alert the user (session) */ TSIP_EventRegister.Signal(TSIP_EventRegister.tsip_register_event_type_t.AO_REGISTER, base.SipSession, response.StatusCode, response.ReasonPhrase, response); /* Alert the user (dialog) */ if (first_time_to_connect) { TSIP_EventDialog.Signal(TSIP_EventDialog.tsip_dialog_event_type_t.Connected, base.SipSession, response.ReasonPhrase, response); } return(ret); }
protected void Signal(TSIP_EventDialog.tsip_dialog_event_type_t eventType, String phrase) { TSIP_EventDialog.Signal(eventType, mSipSession, phrase, null); }