public Chat() { Context.Become(UnInitialized); RecoverAny(UpdateState); ClusterSharding clusterSharding = ClusterSharding.Get(Context.System); _userRegion = clusterSharding.ShardRegion(typeof(User).Name); _chatView = Context.ActorOf(Props.Create(() => new ChatView())); if (_userRegion == null) { _userRegion = clusterSharding.Start( typeName: typeof(User).Name, entityProps: Props.Create <User>(), settings: ClusterShardingSettings.Create(Context.System), messageExtractor: new MessageExtractor(10)); } }
public User() { Context.Become(Unregistered); RecoverAny(UpdateState); Guid userId = Guid.Parse(Self.Path.Name); _userView = Context.ActorOf(Props.Create(() => new UserView())); _userContactsView = Context.ActorOf(Props.Create(() => new UserContactsView())); _userChatView = Context.ActorOf(Props.Create(() => new UserChatView(userId))); _userBadgeView = Context.ActorOf(Props.Create(() => new UserBadgeView(userId))); ClusterSharding clusterSharding = ClusterSharding.Get(Context.System); _region = clusterSharding.ShardRegion(typeof(User).Name); if (_region == null) { _region = clusterSharding.Start( typeName: typeof(User).Name, entityProps: Props.Create <User>(), settings: ClusterShardingSettings.Create(Context.System), messageExtractor: new MessageExtractor(10)); } }