KSLiveChatroomMemberCount.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // KSLiveChatroomMemberCount.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by 王智 on 2022/3/31.
  6. //
  7. #import "KSLiveChatroomMemberCount.h"
  8. @implementation KSLiveChatroomMemberCount
  9. - (NSData *)encode {
  10. NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
  11. [mutableDict setObject:@(self.count) forKey:@"count"];
  12. if (self.senderUserInfo) {
  13. [mutableDict setObject:[self encodeUserInfo:self.senderUserInfo] forKey:@"user"];
  14. }
  15. return [NSJSONSerialization dataWithJSONObject:mutableDict options:kNilOptions error:nil];
  16. }
  17. - (void)decodeWithData:(NSData *)data {
  18. if (data == nil) return;
  19. NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
  20. NSDictionary *json = [[NSDictionary alloc] initWithDictionary:dictionary];
  21. if (json == nil) return;
  22. self.count = [[json ks_stringValueForKey:@"count"] intValue];
  23. NSDictionary *userinfoDic = dictionary[@"user"];
  24. [self decodeUserInfo:userinfoDic];
  25. }
  26. + (NSString *)getObjectName {
  27. return @"RC:Chatroom:MemberCount";
  28. }
  29. - (NSArray<NSString *> *)getSearchableWords {
  30. return nil;
  31. }
  32. + (RCMessagePersistent)persistentFlag {
  33. return MessagePersistent_NONE;
  34. }
  35. @end