]> git.mxchange.org Git - flightgear.git/commitdiff
My understanding of plib's net libs has expanded slightly. A couple of
authorcurt <curt>
Sat, 28 Sep 2002 17:37:44 +0000 (17:37 +0000)
committercurt <curt>
Sat, 28 Sep 2002 17:37:44 +0000 (17:37 +0000)
small mods here reflect that and allow the external network connection
to play better when other net connections (i.e. telnet) are activated.

src/FDM/ExternalNet.cxx
src/FDM/ExternalNet.hxx

index 132003fb60f2a0c2f18255eaa2358168ffba7956..cde754cfe8bd6baab30538473276e3235aeee0d4 100644 (file)
@@ -377,29 +377,33 @@ void FGExternalNet::init() {
 
     char cmd[256];
 
+    HTTPClient *http;
     sprintf( cmd, "/longitude-deg?value=%.8f", lon );
-    new HTTPClient( fdm_host.c_str(), cmd_port, cmd );
-//     cout << "before loop()" << endl;
-    netChannel::loop(0);
-//     cout << "here" << endl;
+    http = new HTTPClient( fdm_host.c_str(), cmd_port, cmd );
+    while ( !http->isDone() ) http->poll(0);
+    delete http;
 
     sprintf( cmd, "/latitude-deg?value=%.8f", lat );
-    new HTTPClient( fdm_host.c_str(), cmd_port, cmd );
-    netChannel::loop(0);
+    http = new HTTPClient( fdm_host.c_str(), cmd_port, cmd );
+    while ( !http->isDone() ) http->poll(0);
+    delete http;
 
     sprintf( cmd, "/ground-m?value=%.8f", ground );
-    new HTTPClient( fdm_host.c_str(), cmd_port, cmd );
-    netChannel::loop(0);
+    http = new HTTPClient( fdm_host.c_str(), cmd_port, cmd );
+    while ( !http->isDone() ) http->poll(0);
+    delete http;
 
     sprintf( cmd, "/heading-deg?value=%.8f", heading );
-    new HTTPClient( fdm_host.c_str(), cmd_port, cmd );
-    netChannel::loop(0);
+    http = new HTTPClient( fdm_host.c_str(), cmd_port, cmd );
+    while ( !http->isDone() ) http->poll(0);
+    delete http;
 
     SG_LOG( SG_IO, SG_INFO, "before sending reset command." );
 
     sprintf( cmd, "/reset?value=ground" );
-    new HTTPClient( fdm_host.c_str(), cmd_port, cmd );
-    netChannel::loop(0);
+    http = new HTTPClient( fdm_host.c_str(), cmd_port, cmd );
+    while ( !http->isDone() ) http->poll(0);
+    delete http;
 
     SG_LOG( SG_IO, SG_INFO, "Remote FDM init() finished." );
 }
index 10ce4ac4d6329daa42e8bede3d19ac62c6a54b72..90b78e0a56c4810404708f1bee8e57038de6d2e8 100644 (file)
 
 class HTTPClient : public netBufferChannel
 {
+
+    bool done;
+
 public:
 
-    HTTPClient ( cchar* host, int port, cchar* path ) {
+    HTTPClient ( cchar* host, int port, cchar* path ) :
+        done( false )
+    {
        open ();
        connect (host, port);
 
@@ -53,7 +58,10 @@ public:
        printf("done\n");
        buffer.remove();
        printf("after buffer.remove()\n");
+        done = true;
     }
+
+    bool isDone() const { return done; }
 };