| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- //
- // KSLiveChatroomWelcome.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/30.
- //
- #import "KSLiveChatroomWelcome.h"
- @implementation KSLiveChatroomWelcome
- - (NSData *)encode {
- NSMutableDictionary *dataDict = [NSMutableDictionary dictionary];
- if (self.msgId) {
- [dataDict setObject:self.msgId forKey:@"msgId"];
- } else {
- [dataDict setObject:@"" forKey:@"msgId"];
- }
- if (self.counts) {
-
- [dataDict setObject:@(self.counts) forKey:@"counts"];
- }
- if (self.rank) {
- [dataDict setObject:@(self.rank) forKey:@"rank"];
- }
- if (self.level) {
-
- [dataDict setObject:@(self.level) forKey:@"level"];
- }
- if (self.extra) {
- [dataDict setObject:self.extra forKey:@"extra"];
- } else {
- [dataDict setObject:@"" forKey:@"extra"];
- }
-
-
- if (self.senderUserInfo) {
- [dataDict setObject:[self encodeUserInfo:self.senderUserInfo] forKey:@"user"];
- }
-
- NSData *data = [NSJSONSerialization dataWithJSONObject:dataDict options:kNilOptions error:nil];
- return data;
- }
- - (void)decodeWithData:(NSData *)data {
- if (data == nil) {
- return;
- }
- NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
- NSDictionary *json = [[NSDictionary alloc] initWithDictionary:dictionary];
- if (json) {
- self.msgId = [json ks_stringValueForKey:@"msgId"];
- self.counts = [[json ks_stringValueForKey:@"counts"] intValue];
- self.rank = [[json ks_stringValueForKey:@"rank"] intValue];
- self.level = [[json ks_stringValueForKey:@"level"] intValue];
-
- self.extra = [json ks_stringValueForKey:@"extra"];
- NSDictionary *userinfoDic = dictionary[@"user"];
- [self decodeUserInfo:userinfoDic];
- }
- }
- + (NSString *)getObjectName {
- return @"RC:Chatroom:Welcome";
- }
- - (NSArray<NSString *> *)getSearchableWords {
- return nil;
- }
- + (RCMessagePersistent)persistentFlag {
- return MessagePersistent_NONE;
- }
- @end
|