Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagec#
themeEmacs
using System;
using Akka.Actor;
using System.Threading.Tasks;
using ServiceB.STUDY;

namespace ServiceB
{
    class Program
    {
        static void Main(string[] args)
        {
            ConsoleKeyInfo cki;
            Console.CancelKeyPress += new ConsoleCancelEventHandler(myHandler);
            Task.Delay(1000).Wait();
            Console.WriteLine("테스트 선택");
            Console.WriteLine("1.RemoteAccessTest");
            Console.WriteLine("2.클러스터-시드노드생성(고정포트)");
            Console.WriteLine("3.클러스터-조인노드생성(랜던포트");
            Console.WriteLine("4.클러스터-예비");
            Console.WriteLine("5.클러스터-예비");
            cki = Console.ReadKey(true);

            AkkaTest akkaTest = new AkkaTest();

            switch (cki.Key)
            {
                case ConsoleKey.D1:
                    akkaTest.remoteTest();
                    break;
                case ConsoleKey.D2:
                    break;
                case ConsoleKey.D3:
                    break;
                case ConsoleKey.D4:
                    break;
                case ConsoleKey.D5:
                    break;
            }

            while (true)
            {
                // 메인 어플리케이션 종료방지를 위한코드 ( ctrl+x 종료 )
                cki = Console.ReadKey(true);
                if (cki.Key == ConsoleKey.X) break;
            }
        }

        protected static void myHandler(object sender, ConsoleCancelEventArgs args)
        {
            args.Cancel = true;
        }
    }
}

//요건 다른 파일에 분리
namespace ServiceB.STUDY
{
    public class AkkaTest
    {
        ActorSystem actorSystem;
        public void remoteTest()
        {
            actorSystem = ActorSystem.Create("ServiceB");
            ActorSelection otherActor = actorSystem.ActorSelection("akka.tcp://ServiceA@127.0.0.1:8001/user/myactor");
            Hello msg = new Hello("hello");
            object result = otherActor.Ask(msg).Result;
            Console.WriteLine("GetMessage:" + result.ToString());
        }
    }
}


단순하게 테스트 코드를 집결 시킬것입니다.