1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- //
- // KSLiveChatroomEnter.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/30.
- //
- #import "KSLiveChatroomEnter.h"
- @implementation KSLiveChatroomEnter
- - (NSData *)encode {
- NSMutableDictionary *multableDict = [NSMutableDictionary dictionary];
- if (self.userId) {
- [multableDict setObject:self.userId forKey:@"userId"];
- } else {
- [multableDict setObject:@"" forKey:@"userId"];
- }
- if (self.userName) {
- [multableDict setObject:self.userName forKey:@"userName"];
- } else {
- [multableDict setObject:@"" forKey:@"userName"];
- }
- if (self.senderUserInfo) {
- [multableDict setObject:[self encodeUserInfo:self.senderUserInfo] forKey:@"user"];
- }
- return [NSJSONSerialization dataWithJSONObject:multableDict options:kNilOptions error:nil];
- }
- - (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 == nil) return;
- self.userId = [json ks_stringValueForKey:@"userId"];
- self.userName = [json ks_stringValueForKey:@"userName"];
- NSDictionary *userinfoDic = dictionary[@"user"];
- [self decodeUserInfo:userinfoDic];
- }
- + (NSString *)getObjectName {
- return @"RC:Chatroom:Enter";
- }
- - (NSArray<NSString *> *)getSearchableWords {
- return nil;
- }
- + (RCMessagePersistent)persistentFlag {
- return MessagePersistent_NONE;
- }
- @end
|