//
//  TrtcUserInfo.m
//  shuto-cne
//
//  Created by 范大德 on 2022/3/21.
//

#import <Foundation/Foundation.h>
#import "TrtcUserInfo.h"
@interface TrtcUserInfo()
{
    NSString* personid;
    NSString* displayName;
    BOOL local;
}

@end
@implementation TrtcUserInfo

- (instancetype)initWithPersonid:(NSString *)userId
{
    personid = userId;
    return self;  // 返回类本身不能忘
}

- (NSString*) personid{
    return personid;
}


-(NSString *)displayName{
    return displayName;
}

-(BOOL)isShareUser{
    return personid != nil && [personid hasPrefix:@"share_"];
}

-(BOOL)isLocalUser{
    return local;
}

-(void)setLocal:(BOOL) value{
    local = value;
}
-(void)setDisplayName:(NSString *)value{
    displayName = value;
}
- (NSUInteger)hash
{
    return [personid hash];
}

- (BOOL)isEqual: (id)obj
{
    if( obj == nil){
        return NO;
    }
    if([obj isKindOfClass: [TrtcUserInfo class]]){
        TrtcUserInfo *user = (TrtcUserInfo*)obj;
        return personid == nil ? [user personid] == nil : [personid isEqual: [user personid]];
    } else if([obj isKindOfClass: [NSString class]]){
        return personid == nil ? obj == nil : [personid isEqual: obj];
    } else {
        return NO;
    }
}
@end
