#import <Foundation/Foundation.h>
#import "ConnectionStateDelegate.h"
#import "MessageListenerDelegate.h"
#import "MessageProcessorDelegate.h"
#import "TaskExecutionTransactionDelegate.h"
#import "SocketProtocolDelegate.h"
#import "AbstractGroupMessage.h"
#import "DeviceGroupKeys.h"
@class BoxedMessage;
typedef NS_CLOSED_ENUM(NSInteger, ConnectionInitiator) {
ConnectionInitiatorApp,
ConnectionInitiatorNotificationExtension,
ConnectionInitiatorShareExtension,
ConnectionInitiatorNotificationHandler,
ConnectionInitiatorThreemaCall,
ConnectionInitiatorThreemaWeb
};
NS_ASSUME_NONNULL_BEGIN
@protocol ServerConnectorProtocol <NSObject, ConnectionStateDelegate, MessageListenerDelegate, MessageProcessorDelegate, TaskExecutionTransactionDelegate>
/**
BusinessInjector for incoming message processor, will be set by Notification Extension to use the same background DB context
*/
@property (nonatomic, readwrite, assign, nullable) NSObject *backgroundEntityManagerForMessageProcessing;
@property (nonatomic, readonly) ConnectionState connectionState;
@property (nonatomic, readonly, nullable) DeviceGroupKeys *deviceGroupKeys;
/**
Encrypted device ID for chat server (CleVer extension).
*/
@property (nonatomic, readonly, nullable) NSData *deviceID;
/// Maximum number of linked devices allowed including this device. This is only set if multi-device is enabled and logged in to mediator
@property (nonatomic, readonly, nullable) NSNumber *maximumNumberOfDeviceSlots;
@property (nonatomic, readwrite) BOOL isAppInBackground;
@property (nonatomic, readonly) BOOL isIPv6Connection;
@property (nonatomic, readonly) BOOL isProxyConnection;
/// Whether we are currently the leader device when MD is active
@property (readonly) BOOL isRolePromotedToLeader;
/**
Connect to chat or mediator server.
@param initiator: Initiator/Caller of connect
@param onCompletion: BOOL true means is trying to connect to the server
*/
- (void)connect:(ConnectionInitiator)initiator onCompletion:(void(^ _Nullable)(BOOL isConnecting))onCompletion NS_SWIFT_NAME(connect(initiator:completionHandler:));
- (void)connectWait:(ConnectionInitiator)initiator NS_SWIFT_NAME(connectWait(initiator:));
- (void)connectWaitDoNotUnblockIncomingMessages:(ConnectionInitiator)initiator NS_SWIFT_NAME(connectWaitDoNotUnblockIncomingMessages(initiator:));
/// Unblock receiving incoming messages
- (void)unblockIncomingMessages;
- (void)disconnect:(ConnectionInitiator)initiator NS_SWIFT_NAME(disconnect(initiator:));
- (void)disconnect:(ConnectionInitiator)initiator force:(BOOL)force NS_SWIFT_NAME(disconnect(initiator:force:));
/**
Wait (max. 3s) for connection state disconnected.
@param initiator: Calling initiator of disconnect
@return BOOL is YES if disconnected
*/
- (BOOL)disconnectWait:(ConnectionInitiator)initiator NS_SWIFT_NAME(disconnectWait(initiator:));
- (void)reconnect;
- (NSString*)nameForConnectionState:(ConnectionState)connectionState;
- (void)deactivateMultiDevice;
- (void)registerConnectionStateDelegate:(id<ConnectionStateDelegate>)delegate NS_SWIFT_NAME(registerConnectionStateDelegate(delegate:));
- (void)unregisterConnectionStateDelegate:(id<ConnectionStateDelegate>)delegate NS_SWIFT_NAME(unregisterConnectionStateDelegate(delegate:));
- (void)registerMessageListenerDelegate:(id<MessageListenerDelegate>)delegate NS_SWIFT_NAME(registerMessageListenerDelegate(delegate:));
- (void)unregisterMessageListenerDelegate:(id<MessageListenerDelegate>)delegate NS_SWIFT_NAME(unregisterMessageListenerDelegate(delegate:));
- (void)registerMessageProcessorDelegate:(id<MessageProcessorDelegate>)delegate NS_SWIFT_NAME(registerMessageProcessorDelegate(delegate:));
- (void)unregisterMessageProcessorDelegate:(id<MessageProcessorDelegate>)delegate NS_SWIFT_NAME(unregisterMessageProcessorDelegate(delegate:));
- (void)registerTaskExecutionTransactionDelegate:(id<TaskExecutionTransactionDelegate>)delegate NS_SWIFT_NAME(registerTaskExecutionTransactionDelegate(delegate:));
- (void)unregisterTaskExecutionTransactionDelegate:(id<TaskExecutionTransactionDelegate>)delegate NS_SWIFT_NAME(unregisterTaskExecutionTransactionDelegate(delegate:));
/**
Reflect message to Mediator server, only if Multi Device is activated.
@warning Must be connected with mediator
@param message Message to reflect, if is not `nil`
@returns ThreemaError
*/
- (NSError * _Nullable)reflectMessage:(NSData*)message;
- (BOOL)sendMessage:(BoxedMessage*)message;
- (BOOL)completedProcessingMessage:(BoxedMessage *)boxmsg;
/**
Set Push Notification Token and send push type apple mc, for receiving Push Notifications in Notification Extension.
@param pushToken Token from registration of Apple Notification Service
*/
- (void)setPushToken:(NSData *)pushToken;
- (void)removePushToken;
- (void)removeVoIPPushToken;
- (void)clearDeviceCookieChangedIndicator;
@end
@interface ServerConnector : NSObject <ServerConnectorProtocol, SocketProtocolDelegate>
@property (nonatomic, readwrite) double lastRtt;
+ (ServerConnector*)sharedServerConnector;
- (instancetype) __unavailable init;
- (void)completedProcessingAbstractMessage:(AbstractMessage *)msg;
- (void)ping;
@end
NS_ASSUME_NONNULL_END
¤ Dauer der Verarbeitung: 0.3 Sekunden
¤
*© Formatika GbR, Deutschland