Guest User

Untitled

a guest
Jul 17th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. // global scope
  2. boost::shared_ptr<HTTP::HTTPService> PhotoUploaderPlugin::globalHTTPService;
  3. boost::weak_ptr<ProxyHandler> PhotoUploaderPlugin::globalProxyHandler;
  4.  
  5. void PhotoUploaderPlugin::StaticInitialize()
  6. {
  7. // Place one-time initialization stuff here; note that there isn't an absolute guarantee that
  8. // this will only execute once per process, just a guarantee that it won't execute again until
  9. // after StaticDeinitialize is called
  10. globalHTTPService = HTTP::HTTPService::create("127.0.0.1", 0, K_LOCALHOST); // Auto-select port
  11.  
  12. boost::shared_ptr<ProxyHandler> proxy(boost::make_shared<ProxyHandler>());
  13. globalProxyHandler = proxy;
  14. globalHTTPService->registerHandler(proxy);
  15. }
  16. void PhotoUploaderPlugin::StaticDeinitialize()
  17. {
  18. // Place one-time deinitialization stuff here
  19. globalHTTPService->terminate();
  20. globalHTTPService.reset(); // Release the shared_ptr
  21. }
  22.  
  23. // Later on (for example in your API class) to get the URI of the web server:
  24. FB::URI base_uri = getPlugin()->m_http->getBaseUri();
  25. // Note that getPlugin() is the function generated by default in your
  26. // root JSAPI class that returns an instance to your plugin object
Add Comment
Please, Sign In to add comment