WFCCUserOnlineState.m 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // WFCCUserOnlineState.m
  3. // WFChatClient
  4. //
  5. // Created by heavyrain on 2022/2/17.
  6. // Copyright © 2022 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCCUserOnlineState.h"
  9. @implementation WFCCClientState
  10. - (id)toJsonObj {
  11. NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
  12. dict[@"platform"] = @(self.platform);
  13. dict[@"state"] = @(self.state);
  14. dict[@"lastSeen"] = @(self.lastSeen);
  15. return dict;
  16. }
  17. @end
  18. @implementation WFCCUserCustomState
  19. - (id)toJsonObj {
  20. NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
  21. dict[@"text"] = self.text;
  22. dict[@"state"] = @(self.state);
  23. return dict;
  24. }
  25. @end
  26. @implementation WFCCUserOnlineState
  27. -(id)toJsonObj {
  28. NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
  29. dict[@"userId"] = self.userId;
  30. dict[@"customState"] = [self.customState toJsonObj];
  31. __block NSMutableArray *arr = [[NSMutableArray alloc] init];
  32. [self.clientStates enumerateObjectsUsingBlock:^(WFCCClientState * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  33. [arr addObject:[obj toJsonObj]];
  34. }];
  35. dict[@"clientStates"] = arr;
  36. return dict;
  37. }
  38. @end