WWWConnection.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #pragma once
  2. @interface UnityWWWConnectionDelegate : NSObject<NSURLConnectionDataDelegate>
  3. {
  4. }
  5. + (id)newDelegateWithURL:(NSURL*)url udata:(void*)udata;
  6. + (id)newDelegateWithCStringURL:(const char*)url udata:(void*)udata;
  7. + (NSMutableURLRequest*)newRequestForHTTPMethod:(NSString*)method url:(NSURL*)url headers:(NSDictionary*)headers;
  8. @property (readonly, retain, nonatomic) NSURL* url;
  9. @property (readonly, retain, nonatomic) NSString* user;
  10. @property (readonly, retain, nonatomic) NSString* password;
  11. @property (readonly, retain, nonatomic) NSData* data;
  12. @property (readonly, retain, atomic) NSURLConnection* connection;
  13. @property (readonly, nonatomic) void* udata;
  14. @property (nonatomic) BOOL shouldAbort;
  15. @end
  16. @interface UnityWWWConnectionSelfSignedCertDelegate : UnityWWWConnectionDelegate
  17. {
  18. }
  19. @end
  20. @protocol UnityWWWRequestProvider<NSObject>
  21. + (NSMutableURLRequest*)allocRequestForHTTPMethod:(NSString*)method url:(NSURL*)url headers:(NSDictionary*)headers;
  22. @end
  23. @interface UnityWWWRequestDefaultProvider : NSObject<UnityWWWRequestProvider>
  24. {
  25. }
  26. + (NSMutableURLRequest*)allocRequestForHTTPMethod:(NSString*)method url:(NSURL*)url headers:(NSDictionary*)headers;
  27. @end
  28. // Put this into mm file with your subclass implementation
  29. // pass subclass name to define
  30. // in case you want custom authentication mecanism, you need to subclass unity WWW delegate
  31. #define IMPL_WWW_DELEGATE_SUBCLASS(ClassName) \
  32. @interface ClassName(OverrideWWWDelegate) \
  33. { \
  34. } \
  35. +(void)load; \
  36. @end \
  37. @implementation ClassName(OverrideWWWDelegate) \
  38. +(void)load \
  39. { \
  40. extern const char* WWWDelegateClassName; \
  41. WWWDelegateClassName = #ClassName; \
  42. } \
  43. @end \
  44. // in case you want to tweak URL request settings you need to implement UnityWWWRequestProvider protocol
  45. #define IMPL_WWW_REQUEST_PROVIDER(ClassName) \
  46. @interface ClassName(OverrideRequestProvider) \
  47. { \
  48. } \
  49. +(void)load; \
  50. @end \
  51. @implementation ClassName(OverrideRequestProvider) \
  52. +(void)load \
  53. { \
  54. extern const char* WWWRequestProviderClassName; \
  55. WWWRequestProviderClassName = #ClassName; \
  56. } \
  57. @end \