-
- HttpdImageChannel() : buffer(512) {
-
- int nWidth = fgGetInt( "/sim/startup/xsize", 800 );
- int nHeight = fgGetInt( "/sim/startup/ysize", 600 );
-
- setTerminator("\r\n");
- JpgFactory = new trJpgFactory();
- JpgFactory -> init( nWidth, nHeight );
- }
-
- ~HttpdImageChannel() {
- JpgFactory -> destroy();
- delete JpgFactory;
- }
-
- virtual void collectIncomingData (const char* s, int n) {
- buffer.append(s,n);
- }
-
- // Handle the actual http request
- virtual void foundTerminator (void);
-};
-
-
-class HttpdImageServer : private simgear::NetChannel
-{
- virtual bool writable (void) { return false ; }
-
- virtual void handleAccept (void) {
- simgear::IPAddress addr ;
- int handle = accept ( &addr ) ;
- SG_LOG( SG_IO, SG_INFO, "Client " << addr.getHost() << ":" << addr.getPort() << " connected" );
-
- HttpdImageChannel *hc = new HttpdImageChannel;
- hc->setHandle ( handle ) ;
- }
-
-public:
-
- HttpdImageServer ( int port ) {
- open ();
- bind( "", port );
- listen( 5 );
-
- printf( "HttpdImage server started on port %d\n", port ) ;
- }
-
-};
-
-
-class FGJpegHttpd : public FGProtocol {
-
- int port;
- HttpdImageServer *imageServer;
-
-public:
-
- inline FGJpegHttpd( int p ) { port = p; }
-
- inline ~FGJpegHttpd() { }