diff --git a/src/src/PEPTransport.h b/src/src/PEPTransport.h new file mode 100644 index 0000000..b53c114 --- /dev/null +++ b/src/src/PEPTransport.h @@ -0,0 +1,79 @@ +#import + +@import PEPObjCTypes_macOS; + +@class PEPTransportConfig; +@class PEPSession; +@class PEPTransport; +@class PEPMessage; + +NS_ASSUME_NONNULL_BEGIN + +@protocol PEPCCSendResultDelegate + +- (BOOL)signalSendMessageResultWithTransportID:(PEPCCTransportID)transportID + messageID:(NSString *)messageID + address:(NSString *)address + statusCode:(PEPCCTransportStatusCode *)statusCode + error:(NSError * _Nullable * _Nullable)error; +@end + +@protocol PEPCCIncomingMessageDelegate + +- (BOOL)signalNewIncomingMessageWithTransportID:(PEPCCTransportID)transportID + statusCode:(PEPCCTransportStatusCode *)statusCode + error:(NSError * _Nullable * _Nullable)error; +@end + +@protocol PEPCCStatusChangeDelegate + +- (BOOL)statusChangedWithTransportID:(PEPCCTransportID)transportID + statusCode:(PEPCCTransportStatusCode *)statusCode + error:(NSError * _Nullable * _Nullable)error; +@end + +/// Idea in a nutshell: +/// - Init with callbacks and callbackExecutionType +/// - configure +/// - startup +/// - listen to status changes (e.g. connected aka "PEPCCTransportStatusCodeReady" +/// - use it: +/// - send message +/// - listen to- and handle sendMessageResult (e.g. done sending aka "PEPCCTransportStatusCodeMessageDelivered") +/// - listen to newIncommingMessage delegate +/// - call nextMessage to get it +/// shutdown +@protocol PEPTransport + +- (instancetype)init; + +/// Convenience initializer. +- (_Nullable instancetype)initWithChangeDelegate:(id _Nullable)statusChangeDelegate + signalSendResultDelegate:(id _Nullable)signalSendResultDelegate + signalIncomingMessageDelegate:(id _Nullable)signalIncomingMessageDelegate + callbackExecutionType:(PEPCCCallbackExcecutionType)callbackExecutionType + error:(NSError * _Nullable * _Nullable)error; + +- (BOOL)configure:(PEPTransport * _Nullable)pEptransport + withConfig:(PEPTransportConfig *)config +transportStatusCode:(out PEPCCTransportStatusCode * _Nullable)tsc + error:(NSError * _Nullable * _Nullable)error; + +- (BOOL)startup:(PEPTransport * _Nullable)pEptransport +transportStatusCode:(out PEPCCTransportStatusCode*)tsc + error:(NSError * _Nullable * _Nullable)error; + +- (BOOL)shutdown:(PEPTransport * _Nullable)pEptransport +transportStatusCode:(out PEPCCTransportStatusCode * _Nullable)tsc + error:(NSError * _Nullable * _Nullable)error; + +- (BOOL)sendMessage:(PEPMessage *)msg pEpSession:(PEPSession * _Nullable)pEpSession +transportStatusCode:(out PEPCCTransportStatusCode * _Nullable)tsc + error:(NSError * _Nullable * _Nullable)error; + +- (PEPMessage * _Nullable)nextMessageWithPEPSession:(PEPSession * _Nullable)pEpsession + transportStatusCode:(out PEPCCTransportStatusCode * _Nullable)tsc + error:(NSError * _Nullable * _Nullable)error; +@end + +NS_ASSUME_NONNULL_END