1
0

svc_http_demuxer.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pragma once
  2. #include "jnetlib/jnetlib_defines.h"
  3. #include "foundation/dispatch.h"
  4. #include "foundation/error.h"
  5. #include "http/ifc_http_demuxer.h"
  6. // {5E3551B0-B0FF-4997-89E4-958545C3EC19}
  7. static const GUID demuxer_service_type_guid =
  8. { 0x5E3551B0, 0xB0FF, 0x4997, { 0x89, 0xE4, 0x95, 0x85, 0x45, 0xC3, 0xEC, 0x19 } };
  9. class svc_http_demuxer: public Wasabi2::Dispatchable
  10. {
  11. protected:
  12. svc_http_demuxer() : Dispatchable(DISPATCHABLE_VERSION) {}
  13. ~svc_http_demuxer() {}
  14. public:
  15. static GUID GetServiceType() { return demuxer_service_type_guid; }
  16. /* returns types to be added to "Accept" HTTP header */
  17. const char *EnumerateAcceptedTypes(size_t i) { return HTTPDemuxerService_EnumerateAcceptedTypes(i); }
  18. /* returns a string to be added to the user-agent (e.g. Ultravox/2.1) */
  19. const char *GetUserAgent() { return HTTPDemuxerService_GetUserAgent(); }
  20. /* allows service to do any necessary customization (mainly for adding headers) */
  21. void CustomizeHTTP(jnl_http_t http) { HTTPDemuxerService_CustomizeHTTP(http); }
  22. /* if you create a demuxer, you now own http and are expected to call jnl_http_release on it when you are done */
  23. /* you can return NErr_TryAgain to let everyone else go first, you'll be called again with pass=1 */
  24. NError CreateDemuxer(nx_uri_t uri, jnl_http_t http, ifc_http_demuxer **demuxer, int pass) { return HTTPDemuxerService_CreateDemuxer(uri, http, demuxer, pass); }
  25. enum
  26. {
  27. DISPATCHABLE_VERSION,
  28. };
  29. protected:
  30. virtual const char *WASABICALL HTTPDemuxerService_EnumerateAcceptedTypes(size_t i) = 0;
  31. virtual const char *WASABICALL HTTPDemuxerService_GetUserAgent() = 0;
  32. virtual void WASABICALL HTTPDemuxerService_CustomizeHTTP(jnl_http_t http) = 0;
  33. virtual NError WASABICALL HTTPDemuxerService_CreateDemuxer(nx_uri_t uri, jnl_http_t http, ifc_http_demuxer **demuxer, int pass) = 0;
  34. };