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.
This commit is contained in:
parent
94441921d6
commit
dc7103245a
2 changed files with 25 additions and 13 deletions
|
@ -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." );
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue