interfacing between transports written in different programming languages
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
3.7 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. #import <Foundation/Foundation.h>
  2. @import PEPObjCTypes_macOS;
  3. @class PEPTransportConfig;
  4. @class PEPSession;
  5. @class PEPTransport;
  6. @class PEPMessage;
  7. NS_ASSUME_NONNULL_BEGIN
  8. @protocol PEPTransportSendToResultDelegate <NSObject>
  9. - (BOOL)signalSendToResultWithTransportID:(PEPTransportID)transportID
  10. messageID:(NSString *)messageID
  11. address:(NSString *)address
  12. statusCode:(PEPTransportStatusCode *)statusCode
  13. error:(NSError * _Nullable * _Nullable)error;
  14. @end
  15. @protocol PEPTransportIncomingMessageDelegate <NSObject>
  16. - (BOOL)signalIncomingMessageWithTransportID:(PEPTransportID)transportID
  17. statusCode:(PEPTransportStatusCode *)statusCode
  18. error:(NSError * _Nullable * _Nullable)error;
  19. @end
  20. @protocol PEPTransportStatusChangeDelegate <NSObject>
  21. - (BOOL)signalStatusChangeWithTransportID:(PEPTransportID)transportID
  22. statusCode:(PEPTransportStatusCode *)statusCode
  23. error:(NSError * _Nullable * _Nullable)error;
  24. @end
  25. /// Idea in a nutshell:
  26. /// - Init with callbacks and callbackExecutionType
  27. /// - configure
  28. /// - startup
  29. /// - listen to status changes (e.g. connected aka "PEPTransportStatusCodeReady"
  30. /// - use it:
  31. /// - send message
  32. /// - listen to- and handle sendMessageResult (e.g. done sending aka "PEPTransportStatusCodeMessageDelivered")
  33. /// - listen to incomingMessage delegate
  34. /// - call nextMessage to get it
  35. /// shutdown
  36. @protocol PEPTransport <NSObject>
  37. @property (weak, nonatomic) id<PEPTransportSendToResultDelegate> signalSendToResultDelegate;
  38. @property (weak, nonatomic) id<PEPTransportIncomingMessageDelegate> signalIncomingMessageDelegate;
  39. @property (weak, nonatomic) id<PEPTransportStatusChangeDelegate> signalStatusChangeDelegate;
  40. - (instancetype)init;
  41. /// Convenience initializer.
  42. - (_Nullable instancetype)initWithSignalStatusChangeDelegate:(id<PEPTransportStatusChangeDelegate> _Nullable)signalStatusChangeDelegate
  43. signalSendToResultDelegate:(id<PEPTransportSendToResultDelegate> _Nullable)signalSendToResultDelegate
  44. signalIncomingMessageDelegate:(id<PEPTransportIncomingMessageDelegate> _Nullable)signalIncomingMessageDelegate
  45. callbackExecutionType:(PEPTransportCallbackExcecutionType)callbackExecutionType
  46. error:(NSError * _Nullable * _Nullable)error;
  47. - (BOOL) configure:(PEPTransport * _Nullable)pEptransport
  48. withConfig:(PEPTransportConfig *)config
  49. transportStatusCode:(out PEPTransportStatusCode * _Nullable)tsc
  50. error:(NSError * _Nullable * _Nullable)error;
  51. - (BOOL) startup:(PEPTransport * _Nullable)pEptransport
  52. transportStatusCode:(out PEPTransportStatusCode*)tsc
  53. error:(NSError * _Nullable * _Nullable)error;
  54. - (BOOL) shutdown:(PEPTransport * _Nullable)pEptransport
  55. transportStatusCode:(out PEPTransportStatusCode * _Nullable)tsc
  56. error:(NSError * _Nullable * _Nullable)error;
  57. - (BOOL) sendMessage:(PEPMessage *)msg pEpSession:(PEPSession * _Nullable)pEpSession
  58. transportStatusCode:(out PEPTransportStatusCode * _Nullable)tsc
  59. error:(NSError * _Nullable * _Nullable)error;
  60. - (PEPMessage * _Nullable)nextMessageWithPEPSession:(PEPSession * _Nullable)pEpsession
  61. transportStatusCode:(out PEPTransportStatusCode * _Nullable)tsc
  62. error:(NSError * _Nullable * _Nullable)error;
  63. @end
  64. NS_ASSUME_NONNULL_END