コード例 #1
0
 public UserLoginActorTest(ITestOutputHelper output, ClusterContextFixture clusterContext)
     : base(output: output)
 {
     clusterContext.Initialize(Sys);
     _clusterContext = clusterContext.Context;
     _client         = new MockClient(_clusterContext);
 }
コード例 #2
0
ファイル: ClusterRoleWorkers.cs プロジェクト: SaladLab/Chatty
 public RoomWorker(ClusterNodeContext context, Config config)
 {
     _context         = context;
     _channelType     = (ChannelType)Enum.Parse(typeof(ChannelType), config.GetString("type", "Tcp"), true);
     _listenEndPoint  = new IPEndPoint(IPAddress.Any, config.GetInt("port", 0));
     _connectEndPoint = new IPEndPoint(IPAddress.Parse(config.GetString("address", "127.0.0.1")), config.GetInt("port", 0));
 }
コード例 #3
0
ファイル: UserLoginActor.cs プロジェクト: SaladLab/Chatty
 public UserLoginActor(ClusterNodeContext clusterContext, ActorBoundChannelRef channel, IPEndPoint clientRemoteEndPoint)
 {
     _logger           = LogManager.GetLogger($"UserLoginActor({clientRemoteEndPoint})");
     _clusterContext   = clusterContext;
     _channel          = channel;
     _isInternalAccess = clientRemoteEndPoint.Address == IPAddress.None;
 }
コード例 #4
0
 public RoomActor(ClusterNodeContext clusterContext, string name)
 {
     _logger         = LogManager.GetLogger(string.Format("RoomActor({0})", name));
     _clusterContext = clusterContext;
     _name           = name;
     _userMap        = new Dictionary <string, UserData>();
 }
コード例 #5
0
ファイル: UserActor.cs プロジェクト: SaladLab/Chatty
 public UserActor(ClusterNodeContext clusterContext, string id, IUserEventObserver observer)
 {
     _logger         = LogManager.GetLogger($"UserActor({id})");
     _clusterContext = clusterContext;
     _id             = id;
     _eventObserver  = (UserEventObserver)observer;
     _enteredRoomMap = new Dictionary <string, RoomRef>();
 }
コード例 #6
0
        public void Dispose()
        {
            if (Context == null)
            {
                return;
            }

            Context.System.Terminate();
            Context = null;
        }
コード例 #7
0
        public BotActor(ClusterNodeContext clusterContext, string name, string roomName, Type patternType)
        {
            _log            = LogManager.GetLogger($"Bot({name})");
            _clusterContext = clusterContext;
            _channel        = Context.InterfacedActorOf(() => new ActorBoundDummyChannel()).Cast <ActorBoundChannelRef>();

            Self.Tell(new StartMessage {
                UserId = name, RoomName = roomName, PatternType = patternType
            });
        }
コード例 #8
0
ファイル: ClusterRoleWorkers.cs プロジェクト: SaladLab/Chatty
        public UserWorker(ClusterNodeContext context, Config config)
        {
            _context        = context;
            _channelType    = (ChannelType)Enum.Parse(typeof(ChannelType), config.GetString("type", "Tcp"), true);
            _listenEndPoint = new IPEndPoint(IPAddress.Any, config.GetInt("port", 0));

            var connectAddress = config.GetString("connect-address");
            var connectPort    = config.GetInt("connect-port", _listenEndPoint.Port);

            _connectEndPoint = new IPEndPoint(connectAddress != null ? IPAddress.Parse(connectAddress) : IPAddress.Loopback, connectPort);
        }
コード例 #9
0
        public MockClient(ClusterNodeContext clusterContex)
        {
            _clusterContext = clusterContex;

            var channel = new TestActorRef <TestActorBoundChannel>(
                _clusterContext.System,
                Props.Create(() => new TestActorBoundChannel(CreateInitialActor)));

            Channel    = channel.UnderlyingActor;
            ChannelRef = channel.Cast <ActorBoundChannelRef>();

            UserLogin = Channel.CreateRef <UserLoginRef>();
        }
コード例 #10
0
        public static async Task <MockClient[]> PrepareLoginedClients(ClusterNodeContext context, int count)
        {
            var clients = new List <MockClient>();

            for (var i = 0; i < count; i++)
            {
                var client = new MockClient(context);
                await client.LoginAsync("test" + i, "1234");

                clients.Add(client);
            }
            return(clients.ToArray());
        }
コード例 #11
0
        public void Initialize(ActorSystem system)
        {
            DeadRequestProcessingActor.Install(system);

            var context = new ClusterNodeContext {
                System = system
            };

            context.ClusterActorDiscovery = system.ActorOf(Props.Create(
                                                               () => new ClusterActorDiscovery(null)));

            context.UserTable = new DistributedActorTableRef <string>(system.ActorOf(
                                                                          Props.Create(() => new DistributedActorTable <string>(
                                                                                           "User", context.ClusterActorDiscovery, null, null)),
                                                                          "UserTable"));

            context.UserTableContainer = new DistributedActorTableContainerRef <string>(system.ActorOf(
                                                                                            Props.Create(() => new DistributedActorTableContainer <string>(
                                                                                                             "User", context.ClusterActorDiscovery, typeof(UserActorFactory), new object[] { context }, InterfacedPoisonPill.Instance)),
                                                                                            "UserTableContainer"));

            context.RoomTable = new DistributedActorTableRef <string>(system.ActorOf(
                                                                          Props.Create(() => new DistributedActorTable <string>(
                                                                                           "Room", context.ClusterActorDiscovery, null, null)),
                                                                          "RoomTable"));

            var roomTableContainer = system.ActorOf(
                Props.Create(() => new DistributedActorTableContainer <string>(
                                 "Room", context.ClusterActorDiscovery, typeof(RoomActorFactory), new object[] { context }, InterfacedPoisonPill.Instance)),
                "RoomTableContainer");

            context.BotTable = new DistributedActorTableRef <long>(system.ActorOf(
                                                                       Props.Create(() => new DistributedActorTable <long>(
                                                                                        "Bot", context.ClusterActorDiscovery, typeof(IncrementalIntegerIdGenerator), null)),
                                                                       "BotTable"));

            var botTableContainer = system.ActorOf(
                Props.Create(() => new DistributedActorTableContainer <long>(
                                 "Bot", context.ClusterActorDiscovery, typeof(BotActorFactory), new object[] { context }, InterfacedPoisonPill.Instance)),
                "BotTableContainer");

            Context = context;
        }
コード例 #12
0
ファイル: UserActorTest.cs プロジェクト: SaladLab/Chatty
 public UserActorTest(ITestOutputHelper output, ClusterContextFixture clusterContext)
     : base(output: output)
 {
     clusterContext.Initialize(Sys);
     _clusterContext = clusterContext.Context;
 }
コード例 #13
0
ファイル: ClusterRoleWorkers.cs プロジェクト: SaladLab/Chatty
 public void Initialize(object[] args)
 {
     _clusterContext = (ClusterNodeContext)args[0];
 }
コード例 #14
0
ファイル: ClusterRoleWorkers.cs プロジェクト: SaladLab/Chatty
 public BotWorker(ClusterNodeContext context, Config config)
 {
     _context = context;
 }
コード例 #15
0
ファイル: ClusterRoleWorkers.cs プロジェクト: SaladLab/Chatty
 public UserTableWorker(ClusterNodeContext context, Config config)
 {
     _context = context;
 }