Work with revised NetChannel poll() API.
This commit is contained in:
parent
931f4266fb
commit
0d6cd11dd4
4 changed files with 23 additions and 6 deletions
|
@ -42,7 +42,7 @@ class HTTPClient : public simgear::NetBufferChannel
|
||||||
|
|
||||||
bool done;
|
bool done;
|
||||||
SGTimeStamp start;
|
SGTimeStamp start;
|
||||||
|
simgear::NetChannelPoller poller;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
HTTPClient ( const char* host, int port, const char* path ) :
|
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 );
|
::snprintf (buffer, 256, "GET %s HTTP/1.0\r\n\r\n", path );
|
||||||
bufferSend(buffer, strlen(buffer) ) ;
|
bufferSend(buffer, strlen(buffer) ) ;
|
||||||
|
|
||||||
|
poller.addChannel(this);
|
||||||
start.stamp();
|
start.stamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +79,11 @@ public:
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void poll(int timeout)
|
||||||
|
{
|
||||||
|
poller.poll(timeout);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
FGExternalNet::FGExternalNet( double dt, string host, int dop, int dip, int cp )
|
FGExternalNet::FGExternalNet( double dt, string host, int dop, int dip, int cp )
|
||||||
|
|
|
@ -58,7 +58,7 @@ using std::string;
|
||||||
class HttpdChannel : public simgear::NetChat
|
class HttpdChannel : public simgear::NetChat
|
||||||
{
|
{
|
||||||
simgear::NetBuffer buffer;
|
simgear::NetBuffer buffer;
|
||||||
|
|
||||||
string urlEncode(string);
|
string urlEncode(string);
|
||||||
string urlDecode(string);
|
string urlDecode(string);
|
||||||
|
|
||||||
|
@ -90,11 +90,18 @@ class HttpdServer : private simgear::NetChannel
|
||||||
|
|
||||||
HttpdChannel *hc = new HttpdChannel;
|
HttpdChannel *hc = new HttpdChannel;
|
||||||
hc->setHandle ( handle );
|
hc->setHandle ( handle );
|
||||||
|
poller.addChannel( hc );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
simgear::NetChannelPoller poller;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
HttpdServer ( int port );
|
HttpdServer ( int port );
|
||||||
|
|
||||||
|
void poll()
|
||||||
|
{
|
||||||
|
poller.poll();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
HttpdServer::HttpdServer(int port)
|
HttpdServer::HttpdServer(int port)
|
||||||
|
@ -116,6 +123,8 @@ HttpdServer::HttpdServer(int port)
|
||||||
SG_LOG( SG_IO, SG_ALERT, "Failed to listen on HTTP port.");
|
SG_LOG( SG_IO, SG_ALERT, "Failed to listen on HTTP port.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
poller.addChannel(this);
|
||||||
|
|
||||||
SG_LOG(SG_IO, SG_ALERT, "Httpd server started on port " << port);
|
SG_LOG(SG_IO, SG_ALERT, "Httpd server started on port " << port);
|
||||||
}
|
}
|
||||||
|
@ -152,8 +161,7 @@ bool FGHttpd::open() {
|
||||||
|
|
||||||
|
|
||||||
bool FGHttpd::process() {
|
bool FGHttpd::process() {
|
||||||
simgear::NetChannel::poll();
|
server->poll();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -594,6 +594,8 @@ FGProps::open()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
poller.addChannel(this);
|
||||||
|
|
||||||
SG_LOG( SG_IO, SG_INFO, "Props server started on port " << port );
|
SG_LOG( SG_IO, SG_INFO, "Props server started on port " << port );
|
||||||
|
|
||||||
set_enabled( true );
|
set_enabled( true );
|
||||||
|
@ -616,7 +618,7 @@ FGProps::close()
|
||||||
bool
|
bool
|
||||||
FGProps::process()
|
FGProps::process()
|
||||||
{
|
{
|
||||||
simgear::NetChannel::poll();
|
poller.poll();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,4 +634,5 @@ FGProps::handleAccept()
|
||||||
<< addr.getHost() << ":" << addr.getPort() );
|
<< addr.getHost() << ":" << addr.getPort() );
|
||||||
PropsChannel* channel = new PropsChannel();
|
PropsChannel* channel = new PropsChannel();
|
||||||
channel->setHandle( handle );
|
channel->setHandle( handle );
|
||||||
|
poller.addChannel( channel );
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ private:
|
||||||
* Server port to listen on.
|
* Server port to listen on.
|
||||||
*/
|
*/
|
||||||
int port;
|
int port;
|
||||||
|
simgear::NetChannelPoller poller;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Create a new TCP server.
|
* Create a new TCP server.
|
||||||
|
|
Loading…
Reference in a new issue