From f071709e4f4a3fa76b3101835ef75bc997b2d6e6 Mon Sep 17 00:00:00 2001 From: Marat Al Date: Thu, 21 Nov 2024 14:26:44 +0100 Subject: [PATCH] Added new fields to the `ARTMessage`. --- Source/ARTBaseMessage.m | 1 + Source/ARTJsonLikeEncoder.m | 2 ++ Source/ARTMessage.m | 3 ++- Source/include/Ably/ARTMessage.h | 17 +++++++++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Source/ARTBaseMessage.m b/Source/ARTBaseMessage.m index 48676a629..7201f09e8 100644 --- a/Source/ARTBaseMessage.m +++ b/Source/ARTBaseMessage.m @@ -21,6 +21,7 @@ - (id)copyWithZone:(NSZone *)zone { message->_data = [self.data copy]; message->_connectionId = self.connectionId; message->_encoding = self.encoding; + message->_extras = self.extras; return message; } diff --git a/Source/ARTJsonLikeEncoder.m b/Source/ARTJsonLikeEncoder.m index d63c08439..8059519bc 100644 --- a/Source/ARTJsonLikeEncoder.m +++ b/Source/ARTJsonLikeEncoder.m @@ -275,6 +275,8 @@ - (ARTMessage *)messageFromDictionary:(NSDictionary *)input { ARTMessage *message = [[ARTMessage alloc] init]; message.id = [input artString:@"id"]; message.name = [input artString:@"name"]; + message.action = ([input artNumber:@"action"] ?: [[NSNumber alloc] initWithInt:ARTMessageCreate]).integerValue; + message.serial = [input artString:@"serial"]; message.clientId = [input artString:@"clientId"]; message.data = [input objectForKey:@"data"]; message.encoding = [input artString:@"encoding"];; diff --git a/Source/ARTMessage.m b/Source/ARTMessage.m index 0ebf065da..eaba86d54 100644 --- a/Source/ARTMessage.m +++ b/Source/ARTMessage.m @@ -40,7 +40,8 @@ - (NSString *)description { - (id)copyWithZone:(NSZone *)zone { ARTMessage *message = [super copyWithZone:zone]; message.name = self.name; - message.extras = self.extras; + message.action = self.action; + message.serial = self.serial; return message; } diff --git a/Source/include/Ably/ARTMessage.h b/Source/include/Ably/ARTMessage.h index 88d145170..e7b827156 100644 --- a/Source/include/Ably/ARTMessage.h +++ b/Source/include/Ably/ARTMessage.h @@ -4,6 +4,17 @@ #import #import +NS_SWIFT_SENDABLE +typedef NS_ENUM(NSUInteger, ARTMessageAction) { + ARTMessageUnset, + ARTMessageCreate, + ARTMessageUpdate, + ARTMessageDelete, + ARTMessageAnnotationCreate, + ARTMessageAnnotationDelete, + ARTMessageMetaOccupancy, +}; + NS_ASSUME_NONNULL_BEGIN /** @@ -14,6 +25,12 @@ NS_ASSUME_NONNULL_BEGIN /// The event name, if available @property (nullable, readwrite, nonatomic) NSString *name; +/// The action identifier +@property (readwrite, nonatomic) ARTMessageAction action; + +/// The serial lexicographic identifier +@property (nullable, readwrite, nonatomic) NSString *serial; + /** * Construct an `ARTMessage` object with an event name and payload. *