From: curt Date: Sat, 28 Sep 2002 17:37:44 +0000 (+0000) Subject: My understanding of plib's net libs has expanded slightly. A couple of X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=dc7103245aa834e4150076a4bb0913db24fbecbf;p=flightgear.git My understanding of plib's net libs has expanded slightly. A couple of small mods here reflect that and allow the external network connection to play better when other net connections (i.e. telnet) are activated. --- diff --git a/src/FDM/ExternalNet.cxx b/src/FDM/ExternalNet.cxx index 132003fb6..cde754cfe 100644 --- a/src/FDM/ExternalNet.cxx +++ b/src/FDM/ExternalNet.cxx @@ -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." ); } diff --git a/src/FDM/ExternalNet.hxx b/src/FDM/ExternalNet.hxx index 10ce4ac4d..90b78e0a5 100644 --- a/src/FDM/ExternalNet.hxx +++ b/src/FDM/ExternalNet.hxx @@ -34,9 +34,14 @@ 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; } };