From 477cfe34768e1f65f3e24e1ee2d20231cf49cc64 Mon Sep 17 00:00:00 2001 From: Adriano Santos Date: Wed, 18 Oct 2023 20:27:24 -0300 Subject: [PATCH] Some adjusts --- lib/src/stateful_named_actor_handler.dart | 36 +++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/src/stateful_named_actor_handler.dart b/lib/src/stateful_named_actor_handler.dart index ffba7f9..09e4b01 100644 --- a/lib/src/stateful_named_actor_handler.dart +++ b/lib/src/stateful_named_actor_handler.dart @@ -46,6 +46,17 @@ class StatefulNamedActorHandler implements ActorHandler { } } + @override + String getRegisteredName() { + String? name = _statefulNamedActorAnnotationInstance?.name; + + if (name == null || name.isEmpty) { + return MirrorSystem.getName(_mirror!.simpleName); + } + + return name; + } + @override spawn_protocol.ActorInvocationResponse handleInvoke( spawn_protocol.ActorInvocation invocation) { @@ -54,25 +65,18 @@ class StatefulNamedActorHandler implements ActorHandler { Optional.of(ReflectHelper.createInstance(actorEntityType!)); if (actorInstance.isEmpty) { - throw StateError("Actor not found Or error during instance creation"); + throw StateError( + "Actor ${invocation.actor.name} not found or error during instance creation"); } - spawn_protocol.ActorInvocationResponse response = - spawn_protocol.ActorInvocationResponse.create() - ..actorName = invocation.actor.name - ..actorSystem = invocation.actor.system - ..updatedContext = spawn_protocol.Context.create(); - return response; - } - - @override - String getRegisteredName() { - String? name = _statefulNamedActorAnnotationInstance?.name; - - if (name == null || name.isEmpty) { - return MirrorSystem.getName(_mirror!.simpleName); + if (actions.containsKey(invocation.actionName)) { + return spawn_protocol.ActorInvocationResponse.create() + ..actorName = invocation.actor.name + ..actorSystem = invocation.actor.system + ..updatedContext = spawn_protocol.Context.create(); } - return name; + throw ArgumentError( + "Action ${invocation.actionName} not found for Actor ${invocation.actor.name}."); } }