[Freeswitch-dev] How to get Peer Session after Bridge (Originate)

Achim Stamm stamm at lyth.de
Fri Oct 29 05:01:39 PDT 2010


Hello,

I have following problem:

I used following code for bridging my current session to multiple Voip 
Phones
in a freeswitch thread (same as bgapi):

switch_ivr_originate(session, &peer_session, &cause, 
"user/60 at 192.168.1.50,user/61 at 192.168.1.50", timelimit, NULL, NULL, 
NULL, NULL, NULL, SOF_NONE,NULL) != SWITCH_STATUS_SUCCESS)

Both Phones with number 60 and 61 rings.

In a special case I need to know when the peer_session hanged up 
(channel is not ready any more).
I use following code for controling my bridged session (The 
peer_session) in another Thread:

while (!peer_session)
      {
            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, 
"Session Nebenstelle is NULL ... Wait\n");
            Sleep(200);
        }
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Session 
Nebenstelle is created from originate call! \n");
        channelNebenstelle = switch_core_session_get_channel(peer_session);
       
        while(switch_channel_ready(channel) && 
switch_channel_ready(channelNebenstelle))
        {
            // Communication :
            Sleep(200);
        }
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Session 
or Peer Session hangsup!\n");
       // doing something special ...


My peer_session is NULL, but Communication is possible.

Why is my peer_session always NULL ?

Is there a better solution (example a core-function) for getting my 
current connected  peer_session ?
I have tried switch_ivr_find_bridged_uuid(my_uuid, other_uuid,255 ); and 
sessionNebenstelle = switch_core_session_locate(other_uuid);
... but I get the session, which have loosed the race.


regards

Achim Stamm

-- 
Achim Stamm, Dipl.-Inform. (FH)


Lyncker & Theis GmbH
Wilhelmstr. 16
65185 Wiesbaden
Germany

Fon +49 611/9006951
Fax +49 611/9406125


Handelsregister: HRB 23156 Amtsgericht Wiesbaden
Steuernummer: 04323897052
USt-IdNr.: DE255806399

Geschäftsführer:
Filip Lyncker,
Armin Theis 




More information about the FreeSWITCH-dev mailing list