×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    98

    How to extract expires time from SIP 200 OK message

    Hi,

    does anyone know howto extract expires field from 200 OK message

    I send publish to server and it answers

    Code:
    SIP/2.0 200 OK
    Record-Route: <sip:xxx.xxx.xxx.xxx;lr;ftag=k3gdejv31dhc7j6lq98u;nat=yes>
    Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5060;rport=56487;received=xxx.xxx.xxx.xxx;branch=z9hG4bK34hdejpvi1hc7p54q98s86k
    To: <sip:joujou@man.com>;tag=c3adb321b3e3ffca4d8376d5ed5c7440.24d2
    From: <sip:jou@man.com>;tag=k3gdejv31dhc7j6lq98u
    CSeq: 36741 PUBLISH
    Call-ID: TWznjULCoId_MZ9h5XNGfv7F_5l3WM
    Contact: <sip:xxx.xxx.xxx.xxx:5070>
    Expires: 585
    SIP-ETag: a.1205157372.31036.15861
    Server: OpenSER (1.2.2-notls (i386/linux))
    Content-Length: 0
    So there is Expires: 585 what I need to get out of that message.
    My application should send publish again before that time is reached. Any ideas?
    I have looked SDPDoc->ConnectionField(); and SDPDoc->AttributeFields(); but cant find howto get that expires time.

    Thanks for helping again

  2. #2
    Registered User
    Join Date
    Jul 2007
    Posts
    40

    Re: How to extract expires time from SIP 200 OK message

    Hi miikkis!

    The element of message that you are interested of is not SDP, but SIP -> using SDP API does no good.

    What you need, is to use SIP API. I assume you are using build-in SIP to send PUBLISH request into network. When 200 OK response is received, use CSIPMessageElements class (UserHeaders() there to be more specific) to read that header you are interested of.

    Hope that helps!
    tkot

  3. #3
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    135

    Re: How to extract expires time from SIP 200 OK message

    Hi Miikkis,

    tkot is right please use the following code when you are decoding the 200 ok response. this is valid for all the user headers, just change the label.

    CSIPRequestElements* reqElem = CONST_CAST( CSIPRequestElements*,aTransaction->RequestElements() );
    const RPointerArray<CSIPHeaderBase>& userHeaders = reqElem->MessageElements().UserHeaders();
    //
    // try to decode the contact header //
    for( TInt a = 0; a < userHeaders.Count(); a++ )
    {
    #ifdef __SERIES60_3X__
    if ( userHeaders[a]->Name().DesC().Compare(_L8("Expires")) == 0 )
    #else
    if ( userHeaders[a]->FullName().Compare(_L8("Expires")) == 0 )
    #endif
    {
    userHeaders[a]->ToTextValueL()->Des() is where you retrieve the conatct information
    }
    }// for


    Jean-philippe
    jean-philippe

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    98

    Re: How to extract expires time from SIP 200 OK message

    Code:
        
    void CSIPEngine::IncomingRequest(CSIPServerTransaction* aTransaction,
    	CSIPDialog& aDialog )
    else if ( aTransaction->Type() == 
        SIPStrings::StringF( SipStrConsts::EPhraseOk ))
        	{
        	CSIPRequestElements* reqElem = CONST_CAST( CSIPRequestElements*,aTransaction->RequestElements() );
        	const RPointerArray<CSIPHeaderBase>& userHeaders = reqElem->MessageElements().UserHeaders();
        	//
        	// try to decode the contact header //
        	for( TInt a = 0; a < userHeaders.Count(); a++ )
        		{
        		if ( userHeaders[a]->Name().DesC().Compare(_L8("Expires")) == 0 )
        			{
        			iExpiresTime.Copy(userHeaders[a]->ToTextValueL()->Des());
        			}
        		}
        	}
    I tried that and iExpiresTime is empty after receiving 200 ok.
    There is so many IncomingRequest() in example sip engine so I dont know where is should put that code

    I think it is time for some debugging

  5. #5
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    135

    Re: How to extract expires time from SIP 200 OK message

    Miikkis,

    the publish 200 ok is received via the following callback method

    IncomingResponse( CSIPClientTransaction& aTransaction )

    don't forget to handle the etag header.

    Hope that it's gonna solve your problem.

    Jean-philippe
    jean-philippe

  6. #6
    Registered User
    Join Date
    Nov 2007
    Posts
    98

    Re: How to extract expires time from SIP 200 OK message

    Thanks very much for helping me out of this
    Code:
    // -----------------------------------------------------------------------------
    // CSIPEngine::IncomingResponse - No implementation needed
    // -----------------------------------------------------------------------------
    void CSIPEngine::IncomingResponse( 
        CSIPClientTransaction&  aTransaction  )
    	{
        if ( aTransaction.Type() == 
        SIPStrings::StringF( SipStrConsts::EPhraseOk ))
        	{
        	CSIPResponseElements* reqElem = CONST_CAST( CSIPResponseElements*, aTransaction.ResponseElements() );
        	const RPointerArray<CSIPHeaderBase>& userHeaders = reqElem->MessageElements().UserHeaders();
        	//
        	// try to decode the contact header //
        	for( TInt a = 0; a < userHeaders.Count(); a++ )
        		{
        		if ( userHeaders[a]->Name().DesC().Compare(_L8("Expires")) == 0 )
        			{
        			iExpiresTime.Copy(userHeaders[a]->ToTextValueL()->Des());
        			}
        		}
        	}
    	}
    I did this and tried to debug, anyway when server sends 200 ok debug doest go to that callback method. (and I looked all other IncomingResponse methods) so where is problem

    I changed ur code a little, there was
    Code:
    CSIPRequestElements* reqElem = CONST_CAST( CSIPRequestElements*,aTransaction->RequestElements() );
    and there isnt RequestElements, but there was ResponseElements. I think that is correct?

    edit1
    I send now iObserver->WriteLog to my main application and when 200 OK is received writelog doesnt get notify. I put that writelog call to every response received and requestreceived funktion and still nothing

    edit2
    Do I use sip engine wrong?
    in UI
    Code:
    constructL()
    iSipEngine = CSIPEngine::NewL(KUidSIPExApp, this );
    
    sendpublish()
    iSipEngine->EnableProfile;
    iSipEngine->Publish(writeBuffer);
    SipEngine
    Code:
    EXPORT_C void CSIPEngine::Publish(const TDesC8& aData)
    	{
    	 
    	//get aor from the profile
    	 
    	// Create the From header value using info from the profile
        const TDesC8* aor = NULL;
        iProfile->GetParameter( KSIPUserAor, aor );
    	
    	 
    	 
    	CSIPAddress* toAddress =CSIPAddress::DecodeL(*aor);
    	CleanupStack::PushL(toAddress);
    	 
    	CSIPToHeader* toHeader = CSIPToHeader::NewL(toAddress);
    	CleanupStack::Pop(toAddress);
    	CleanupStack::PushL(toHeader);
    	CUri8* uri = ConvertToUri8LC(*aor);
    	CSIPRequestElements* reqElems = CSIPRequestElements::NewL(uri); 
    	CSIPMessageElements& MessageElements1=reqElems->MessageElements();
    	 
    	
    	MessageElements1.SetContentL(aData.AllocL(),
    	    CSIPContentTypeHeader::NewL(_L8("application"),_L8("pidf+xml")));
    	 
    	RPointerArray <CSIPHeaderBase> myheader1(1);
    	 
    	CSIPEventHeader* EventHeader1=CSIPEventHeader::NewL ( _L8("presence")); 
    	myheader1.Append(EventHeader1);
    	 
    	MessageElements1.SetUserHeadersL(myheader1);
    	 
    	CleanupStack::Pop(); //toHeader
    	 
    	CleanupStack::PushL(reqElems);
    	RStringPool pool = SIPStrings::Pool();
    	
    	RStringF str = pool.OpenFStringL(_L8("PUBLISH"));
    	reqElems->SetMethodL(str);
    	 
    	 
    	
    	// Get the current connection
    	CSIPConnection& conn = ConnectionL();
    
    	// Send the request using the connection (ownership of the
    	// request elements object is transferred)
    	//CSIPClientTransaction* ctx = conn.SendRequestL( reqElem );
    	CSIPClientTransaction* ctx = conn.SendRequestL( reqElems, *iProfile );
    	CleanupStack::Pop( reqElems );
    
    	delete ctx;
    	 
    	 
    	}
    is there something missing what causes that I dont get server responses?
    Last edited by miikkis; 2008-04-02 at 11:46.

  7. #7
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    135

    Re: How to extract expires time from SIP 200 OK message

    Miikkis,

    you need to use
    const RPointerArray<CSIPHeaderBase>& userHeaders = aTransaction.ResponseElements()->MessageElements().UserHeaders();

    when decoding the response.

    you should study carefully the sip example.

    when iSipEngine->EnableProfile; is used the phone sends a register and teh server sends back a 200 ok which triggers ProfileRegistrationStatusChanged() with a iProfile->Status() = CSIPProfile::ERegistered status

    at that time you can retrieve the connection object and send request. Before i think you can't

    so you cannot chain enableprofile and send publish (unless the phone is already registered with the selected profile)

    Jean-philippe
    jean-philippe

  8. #8
    Registered User
    Join Date
    Nov 2007
    Posts
    98

    Re: How to extract expires time from SIP 200 OK message

    ok I find reason why my app didnt get responses.

    When I do this in
    Code:
    TBuf8<128> buf;
    	if ( statusCode == 200 )
       	{
        	const RPointerArray<CSIPHeaderBase>& userHeaders = respElem->MessageElements().UserHeaders();
        	//
        	// try to decode the contact header //
        	for( TInt a = 0; a < userHeaders.Count(); a++ )
        		{
        		buf.Copy(userHeaders[a]->Name().DesC());
        		if ( buf.Compare(_L8("Expires")) == 0 )
        			{
        			iExpiresTime.Copy(userHeaders[a]->ToTextValueL()->Des());
        			}
        		}
    buf is empty every time. anyway userHeaders.Count(); returns 4.
    I think that there is somekind problem on line
    const RPointerArray<CSIPHeaderBase>& userHeaders = respElem->MessageElements().UserHeaders();

    any ideas?

  9. #9
    Registered User
    Join Date
    Nov 2007
    Posts
    98

    Re: How to extract expires time from SIP 200 OK message

    wohoo now it works

    here is code if some1 else needs it sometime
    Code:
    void CSIPEngine::IncomingResponse( 
        CSIPClientTransaction&  aTransaction  )
    	{
    const CSIPResponseElements* respElem = CONST_CAST( CSIPResponseElements*, aTransaction.ResponseElements() );
    
    	TUint statusCode = respElem->StatusCode();
    	
    	if ( statusCode == 200 )
       	{
        	const RPointerArray<CSIPHeaderBase>& userHeaders = respElem->MessageElements().UserHeaders();
        	//
        	// try to decode the contact header //
        	for( TInt a = 0; a < userHeaders.Count(); a++ )
        		{
        		const CSIPHeaderBase* header = userHeaders[ a ];
        	
        		if ( header->Name() == SIPStrings::StringF( SipStrConsts::EExpiresHeader ) )
        			{
        			iExpiresTime.Copy(userHeaders[a]->ToTextValueL()->Des());
        			}
        		}
        	iObserver->WriteLog( iExpiresTime );
        	}
     }
    many thanks to jcaradec helping me on this

Similar Threads

  1. sip send MESSAGE on Nokia E61 fails.
    By infy_gcl in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2009-11-30, 11:15
  2. SIP Refresh Registeration TIme
    By saji_iq in forum VoIP
    Replies: 4
    Last Post: 2008-08-13, 15:48
  3. SIP originated Message Delivered!
    By forceps in forum VoIP
    Replies: 4
    Last Post: 2007-11-29, 04:11
  4. Problem regarding SIP
    By sanjayraj in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2007-04-17, 06:39
  5. Nokia 3360 error message when trying to sync for the 1st time using IR and
    By Nokia_Archived in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2002-05-24, 20:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •