| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- //
- // RCChatroomSeatsControl.m
- // StudentDaya
- //
- // Created by Kyle on 2022/2/21.
- // Copyright © 2022 DayaMusic. All rights reserved.
- //
- #import "RCChatroomSeatsControl.h"
- @implementation RCChatroomSeatsControl
- - (NSData *)encode {
- NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
- if (self.userId) {
- [mutableDict setObject:self.userId forKey:@"userId"];
- } else {
- [mutableDict setObject:@"" forKey:@"userId"];
- }
- if (self.userName) {
- [mutableDict setObject:self.userName forKey:@"userName"];
- } else {
- [mutableDict setObject:@"" forKey:@"userName"];
- }
- [mutableDict setObject:@(self.seatBan) forKey:@"seatBan"];
- if (self.senderUserInfo) {
- [mutableDict setObject:[self encodeUserInfo:self.senderUserInfo] forKey:@"user"];
- }
- return [NSJSONSerialization dataWithJSONObject:mutableDict 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"];
- self.seatBan = [[json ks_stringValueForKey:@"seatBan"] boolValue];
- NSDictionary *userinfoDic = dictionary[@"user"];
- [self decodeUserInfo:userinfoDic];
- }
- + (NSString *)getObjectName {
- return @"RC:Chatroom:SeatsCtrl";
- }
- - (NSArray<NSString *> *)getSearchableWords {
- return nil;
- }
- + (RCMessagePersistent)persistentFlag {
- return MessagePersistent_NONE;
- }
- @end
|