WFCUConferenceChangeModelContent.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // WFCUConferenceChangeModelContent.m
  3. // WFChatUIKit
  4. //
  5. // Created by Tom Lee on 2021/2/15.
  6. // Copyright © 2020 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCUConferenceChangeModelContent.h"
  9. @implementation WFCUConferenceChangeModelContent
  10. -(WFCCMessagePayload *)encode {
  11. WFCCMessagePayload *payload = [super encode];
  12. payload.content = self.conferenceId;
  13. NSMutableDictionary *dataDict = [NSMutableDictionary dictionary];
  14. if (self.isAudience) {
  15. [dataDict setObject:@(YES) forKey:@"a"];
  16. }
  17. payload.binaryContent = [NSJSONSerialization dataWithJSONObject:dataDict
  18. options:kNilOptions
  19. error:nil];
  20. return payload;
  21. }
  22. -(void)decode:(WFCCMessagePayload *)payload {
  23. self.conferenceId = payload.content;
  24. NSError *__error = nil;
  25. NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:payload.binaryContent
  26. options:kNilOptions
  27. error:&__error];
  28. if (!__error) {
  29. self.isAudience = [dictionary[@"a"] boolValue];
  30. }
  31. }
  32. + (int)getContentType {
  33. return VOIP_CONTENT_CONFERENCE_CHANGE_MODE;
  34. }
  35. + (int)getContentFlags {
  36. return WFCCPersistFlag_TRANSPARENT;
  37. }
  38. + (void)load {
  39. [[WFCCIMService sharedWFCIMService] registerMessageContent:self];
  40. }
  41. @end