voltando a versao de n aberturas e fechamentos de sockets

Dependencies:   EthernetInterface NTPClient mbed-rtos_old mbed

Fork of header_main_public by VZTECH

Revision:
10:22da1a0ac1e1
Parent:
8:e3bfe62a477e
Child:
12:07fd716e0f35
--- a/call_box.cpp	Mon Sep 15 17:51:46 2014 +0000
+++ b/call_box.cpp	Mon Sep 15 20:55:48 2014 +0000
@@ -12,8 +12,8 @@
     timeslice = 0x00;
     status = cb_idle;
     //Sip sip( ext, port );
-    //sip = NULL;
-    sip = new Sip( ext, port );
+    sip = NULL;
+    //sip = new Sip( ext, port );
 }
 
 Call_Box::~Call_Box( void ){
@@ -77,9 +77,9 @@
         
         VZ_call * call = sip->invite();
         
-        delete( sip );
-        this->sip = NULL;
-        
+        //delete( sip );
+        //this->sip = NULL;
+        debug_msg("nao metei o socket");
         debug_msg("Valor do retorno do invite :: %p ", call );        
         return( call );
     }else{
@@ -108,8 +108,14 @@
         }else return( 0 );
     }else{
         if( status == cb_on_call || status == cb_idle ){
-            return ( sip->listen_SIP_server() );
-        } else return( 0 );
+            //return ( sip->listen_SIP_server() );
+            int out_read = sip->listen_SIP_server();
+            if( out_read > 0 ){
+                delete( sip );
+                this->sip = NULL;
+            }
+            return( out_read );
+        }else return( 0 );
     }
 }
 
@@ -128,16 +134,17 @@
 //}
 
 void Call_Box::send_bye( void ){ 
+    debug_msg("");
     if( this->sip == NULL ){
         this->sip = new Sip( ext, port );
         
         sip->send_bye();
-        
-        delete( sip );
-        
+        debug_msg("");
+        delete( sip );    
         sip = NULL;
     }else{
         sip->send_bye();
+        debug_msg("");
     }
 }