1
0
Fork 0

Work with revised NetChannel poll() API.

This commit is contained in:
James Turner 2013-06-09 19:12:04 +01:00
parent 931f4266fb
commit 0d6cd11dd4
4 changed files with 23 additions and 6 deletions

View file

@ -42,7 +42,7 @@ class HTTPClient : public simgear::NetBufferChannel
bool done;
SGTimeStamp start;
simgear::NetChannelPoller poller;
public:
HTTPClient ( const char* host, int port, const char* path ) :
@ -55,6 +55,7 @@ public:
::snprintf (buffer, 256, "GET %s HTTP/1.0\r\n\r\n", path );
bufferSend(buffer, strlen(buffer) ) ;
poller.addChannel(this);
start.stamp();
}
@ -78,6 +79,11 @@ public:
return done;
}
}
void poll(int timeout)
{
poller.poll(timeout);
}
};
FGExternalNet::FGExternalNet( double dt, string host, int dop, int dip, int cp )

View file

@ -58,7 +58,7 @@ using std::string;
class HttpdChannel : public simgear::NetChat
{
simgear::NetBuffer buffer;
string urlEncode(string);
string urlDecode(string);
@ -90,11 +90,18 @@ class HttpdServer : private simgear::NetChannel
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)
@ -116,6 +123,8 @@ 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);
}
@ -152,8 +161,7 @@ bool FGHttpd::open() {
bool FGHttpd::process() {
simgear::NetChannel::poll();
server->poll();
return true;
}

View file

@ -594,6 +594,8 @@ FGProps::open()
return false;
}
poller.addChannel(this);
SG_LOG( SG_IO, SG_INFO, "Props server started on port " << port );
set_enabled( true );
@ -616,7 +618,7 @@ FGProps::close()
bool
FGProps::process()
{
simgear::NetChannel::poll();
poller.poll();
return true;
}
@ -632,4 +634,5 @@ FGProps::handleAccept()
<< addr.getHost() << ":" << addr.getPort() );
PropsChannel* channel = new PropsChannel();
channel->setHandle( handle );
poller.addChannel( channel );
}

View file

@ -49,7 +49,7 @@ private:
* Server port to listen on.
*/
int port;
simgear::NetChannelPoller poller;
public:
/**
* Create a new TCP server.