Page History
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
public class EchoActor Hello { public Hello(string message) { Message = message; } public string Message { get; private set; } } public class EchoActor2 : ReceiveActor { public EchoActorEchoActor2() { Receive<Hello>(hello => { Console.WriteLine("[{0}]: {1}", Sender, hello.Message); Sender.Tell(hello); }); } } public class Hello { public Hello(string message)); { Message = message; } public string Message { get; private set; } } |
전송에 사용될 Class는 공용 DLL에 정의 되어 , 공용 DLL에 위 내용을 추가한후
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
using (ActorSystem actorSystem = ActorSystem.Create("ServiceB")) { //자신이 가진액터가 아닌, 원격지의 액터 선택이기 때문에 ActorSelection 을 사용합니다. ActorSelection otherActor = actorSystem.ActorSelection("akka.tcp://ServiceA@127.0.0.1:8001/user/myactor"); Hello msg = new Hello("Hello"); otherActor.Tell("Hello"msg); //콘솔 종료 방지 코드 생략... } //동일 컴퓨터이니 ServiceB의 설정포트를 8002로 변경 |
...