Skip to content

Commit

Permalink
Added new fields to the ARTMessage.
Browse files Browse the repository at this point in the history
  • Loading branch information
maratal committed Nov 25, 2024
1 parent a241afa commit eaa3662
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
1 change: 1 addition & 0 deletions Source/ARTBaseMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions Source/ARTJsonLikeEncoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -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:ARTMessageActionCreate]).integerValue;
message.serial = [input artString:@"serial"];
message.clientId = [input artString:@"clientId"];
message.data = [input objectForKey:@"data"];
message.encoding = [input artString:@"encoding"];;
Expand Down
3 changes: 2 additions & 1 deletion Source/ARTMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
41 changes: 41 additions & 0 deletions Source/include/Ably/ARTMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,41 @@
#import <Ably/ARTTypes.h>
#import <Ably/ARTChannelOptions.h>

/**
* The namespace containing the different types of message actions.
*/
NS_SWIFT_SENDABLE
typedef NS_ENUM(NSUInteger, ARTMessageAction) {
/**
* Message action has not been set.
*/
ARTMessageActionUnset,
/**
* Message action for a newly created message.
*/
ARTMessageActionCreate,
/**
* Message action for an updated message.
*/
ARTMessageActionUpdate,
/**
* Message action for a deleted message.
*/
ARTMessageActionDelete,
/**
* Message action for a newly created annotation.
*/
ARTMessageActionAnnotationCreate,
/**
* Message action for a deleted annotation.
*/
ARTMessageActionAnnotationDelete,
/**
* Message action for a meta-message that contains channel occupancy information.
*/
ARTMessageActionMetaOccupancy,
};

NS_ASSUME_NONNULL_BEGIN

/**
Expand All @@ -14,6 +49,12 @@ NS_ASSUME_NONNULL_BEGIN
/// The event name, if available
@property (nullable, readwrite, nonatomic) NSString *name;

/// The action type of the message, one of the `ARTMessageAction` enum values.
@property (readwrite, nonatomic) ARTMessageAction action;

/// This message's unique serial.
@property (nullable, readwrite, nonatomic) NSString *serial;

/**
* Construct an `ARTMessage` object with an event name and payload.
*
Expand Down

0 comments on commit eaa3662

Please sign in to comment.