Expose HTTP client to Canvas.
This commit is contained in:
parent
efcc89480d
commit
f0ef2b9576
3 changed files with 21 additions and 3 deletions
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include <Main/globals.hxx>
|
#include <Main/globals.hxx>
|
||||||
#include <Main/util.hxx>
|
#include <Main/util.hxx>
|
||||||
|
#include <Network/HTTPClient.hxx>
|
||||||
#include <Viewer/renderer.hxx>
|
#include <Viewer/renderer.hxx>
|
||||||
|
|
||||||
#include <osgDB/ReadFile>
|
#include <osgDB/ReadFile>
|
||||||
|
@ -98,4 +99,19 @@ namespace canvas
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
simgear::HTTP::Client* FGCanvasSystemAdapter::getHTTPClient() const
|
||||||
|
{
|
||||||
|
FGHTTPClient* http =
|
||||||
|
static_cast<FGHTTPClient*>(globals->get_subsystem("http"));
|
||||||
|
|
||||||
|
if( http )
|
||||||
|
return http->client();
|
||||||
|
|
||||||
|
SG_LOG( SG_IO,
|
||||||
|
SG_ALERT,
|
||||||
|
"FGCanvasSystemAdapter: Failed to get HTTP subsystem" );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ namespace canvas
|
||||||
virtual void addCamera(osg::Camera* camera) const;
|
virtual void addCamera(osg::Camera* camera) const;
|
||||||
virtual void removeCamera(osg::Camera* camera) const;
|
virtual void removeCamera(osg::Camera* camera) const;
|
||||||
virtual osg::Image* getImage(const std::string& path) const;
|
virtual osg::Image* getImage(const std::string& path) const;
|
||||||
|
virtual simgear::HTTP::Client* getHTTPClient() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ static naRef f_http_load(const nasal::CallContext& ctx)
|
||||||
naRef initNasalHTTP(naRef globals, naContext c)
|
naRef initNasalHTTP(naRef globals, naContext c)
|
||||||
{
|
{
|
||||||
using simgear::HTTP::Request;
|
using simgear::HTTP::Request;
|
||||||
|
typedef Request* (Request::*HTTPCallback)(const Request::Callback&);
|
||||||
NasalRequest::init("http.Request")
|
NasalRequest::init("http.Request")
|
||||||
.member("url", &Request::url)
|
.member("url", &Request::url)
|
||||||
.member("method", &Request::method)
|
.member("method", &Request::method)
|
||||||
|
@ -94,9 +95,9 @@ naRef initNasalHTTP(naRef globals, naContext c)
|
||||||
.member("reason", &Request::responseReason)
|
.member("reason", &Request::responseReason)
|
||||||
.member("readyState", &Request::readyState)
|
.member("readyState", &Request::readyState)
|
||||||
.method("abort", static_cast<void (Request::*)()>(&Request::abort))
|
.method("abort", static_cast<void (Request::*)()>(&Request::abort))
|
||||||
.method("done", &Request::done)
|
.method("done", static_cast<HTTPCallback>(&Request::done))
|
||||||
.method("fail", &Request::fail)
|
.method("fail", static_cast<HTTPCallback>(&Request::fail))
|
||||||
.method("always", &Request::always);
|
.method("always", static_cast<HTTPCallback>(&Request::always));
|
||||||
|
|
||||||
using simgear::HTTP::FileRequest;
|
using simgear::HTTP::FileRequest;
|
||||||
NasalFileRequest::init("http.FileRequest")
|
NasalFileRequest::init("http.FileRequest")
|
||||||
|
|
Loading…
Add table
Reference in a new issue