WFCCPCOnlineInfo.m 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // WFCCPCOnlineInfo.m
  3. // WFChatClient
  4. //
  5. // Created by Tom Lee on 2020/4/6.
  6. // Copyright © 2020 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCCPCOnlineInfo.h"
  9. @implementation WFCCPCOnlineInfo
  10. + (instancetype)infoFromStr:(NSString *)strInfo withType:(WFCCPCOnlineType)type {
  11. WFCCPCOnlineInfo *info = [[WFCCPCOnlineInfo alloc] init];
  12. info.type = type;
  13. if (strInfo.length) {
  14. info.isOnline = YES;
  15. NSArray<NSString *> *parts = [strInfo componentsSeparatedByString:@"|"];
  16. if (parts.count >= 4) {
  17. info.timestamp = [parts[0] longLongValue];
  18. info.platform = [parts[1] intValue];
  19. info.clientId = parts[2];
  20. info.clientName = parts[3];
  21. }
  22. } else {
  23. info.isOnline = NO;
  24. }
  25. return info;
  26. }
  27. - (id)toJsonObj {
  28. NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
  29. dict[@"clientId"] = self.clientId;
  30. dict[@"clientName"] = self.clientName;
  31. dict[@"type"] = @(self.type);
  32. dict[@"isOnline"] = @(self.isOnline);
  33. dict[@"platform"] = @(self.platform);
  34. [self setDict:dict key:@"timestamp" longlongValue:self.timestamp];
  35. return dict;
  36. }
  37. @end