WFCCPTextMessageContent.m 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // WFCCPTextMessageContent.m
  3. // WFChatClient
  4. //
  5. // Created by heavyrain on 2017/8/16.
  6. // Copyright © 2017年 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCCPTextMessageContent.h"
  9. #import "WFCCIMService.h"
  10. #import "Common.h"
  11. @implementation WFCCPTextMessageContent
  12. - (WFCCMessagePayload *)encode {
  13. WFCCMessagePayload *payload = [super encode];
  14. payload.contentType = [self.class getContentType];
  15. payload.searchableContent = self.text;
  16. return payload;
  17. }
  18. - (void)decode:(WFCCMessagePayload *)payload {
  19. [super decode:payload];
  20. self.text = payload.searchableContent;
  21. }
  22. + (int)getContentType {
  23. return MESSAGE_CONTENT_TYPE_P_TEXT;
  24. }
  25. + (int)getContentFlags {
  26. return WFCCPersistFlag_PERSIST;
  27. }
  28. + (instancetype)contentWith:(NSString *)text {
  29. WFCCPTextMessageContent *content = [[WFCCPTextMessageContent alloc] init];
  30. content.text = text;
  31. return content;
  32. }
  33. + (void)load {
  34. [[WFCCIMService sharedWFCIMService] registerMessageContent:self];
  35. }
  36. - (NSString *)digest:(WFCCMessage *)message {
  37. return self.text;
  38. }
  39. @end