/// <summary> /// This method sets the actor so that it can "boot" itself up. /// </summary> private void Initializing() { _logger.Debug("Initializing."); //Request from parent the list of child actor IActorRefs to request the state from them Context.Parent.Tell(new ClientGetChildActorRefs(Self, null)); // // Handle Responses // Receive <ClientGetChildActorRefsResponse>(r => { _logger.Debug("Received child actor references."); // Go get the child actor states foreach (IActorRef childActorRef in r.ListOfChildActorRefs) { _logger.Debug($"Requesting child state from:{childActorRef.Path.Name}"); ClientGetStateRequest newRequest = new ClientGetStateRequest(Self); childActorRef.Tell(newRequest); _PendingRequests.Add(newRequest); } }); // Save the client state Receive <ClientGetStateResponse>(r => { _logger.Debug($"Received child actor state from:{Sender.Path.Name}"); if (r.ReplyClientState != null) { _ActorState.Add(r.ReplyClientState.Id, r.ReplyClientState); } _PendingRequests.Remove(r.OriginalRequest as ClientGetStateRequest); if (_PendingRequests.Count == 0) { _logger.Info("Received all Client actor states."); Become(Ready); } }); // Reply to self with a null client state Receive <ClientGetStateRequest>(r => { Sender.Tell(new ClientGetStateResponse(r.Requestor, null, r)); }); Receive <SubscribedForCommandEvents>(r => { _logger.Info($"Subscribed for '{r.Id}' command events"); }); // This catch all will log if there are any weird unhandled messages. Receive <object>(message => { Stash.Stash(); _logger.Debug($"Stashing unhandled message from:{Sender.Path.ToStringWithAddress()} Got Unhandled Message:{message.GetType().Name}"); }); _logger.Debug("Initialized."); }
public ClientGetStateResponse(IActorRef originalRequestor, ClientState clientState, ClientGetStateRequest originalRequest) : base(originalRequestor, clientState, originalRequest) { }