bool done;
SGTimeStamp start;
-
+ simgear::NetChannelPoller poller;
public:
HTTPClient ( const char* host, int port, const char* path ) :
::snprintf (buffer, 256, "GET %s HTTP/1.0\r\n\r\n", path );
bufferSend(buffer, strlen(buffer) ) ;
+ poller.addChannel(this);
start.stamp();
}
return done;
}
}
+
+ void poll(int timeout)
+ {
+ poller.poll(timeout);
+ }
};
FGExternalNet::FGExternalNet( double dt, string host, int dop, int dip, int cp )
class HttpdChannel : public simgear::NetChat
{
simgear::NetBuffer buffer;
-
+
string urlEncode(string);
string urlDecode(string);
HttpdChannel *hc = new HttpdChannel;
hc->setHandle ( handle );
+ poller.addChannel( hc );
}
+ simgear::NetChannelPoller poller;
public:
HttpdServer ( int port );
+
+ void poll()
+ {
+ poller.poll();
+ }
};
HttpdServer::HttpdServer(int port)
SG_LOG( SG_IO, SG_ALERT, "Failed to listen on HTTP port.");
return;
}
+
+ poller.addChannel(this);
SG_LOG(SG_IO, SG_ALERT, "Httpd server started on port " << port);
}
bool FGHttpd::process() {
- simgear::NetChannel::poll();
-
+ server->poll();
return true;
}
return false;
}
+ poller.addChannel(this);
+
SG_LOG( SG_IO, SG_INFO, "Props server started on port " << port );
set_enabled( true );
bool
FGProps::process()
{
- simgear::NetChannel::poll();
+ poller.poll();
return true;
}
<< addr.getHost() << ":" << addr.getPort() );
PropsChannel* channel = new PropsChannel();
channel->setHandle( handle );
+ poller.addChannel( channel );
}
* Server port to listen on.
*/
int port;
-
+ simgear::NetChannelPoller poller;
public:
/**
* Create a new TCP server.