Example #1
0
 public UserLoginActorTest(ITestOutputHelper output, ClusterContextFixture clusterContext)
     : base(output: output)
 {
     clusterContext.Initialize(Sys);
     _clusterContext = clusterContext.Context;
     _client         = new MockClient(_clusterContext);
 }
Example #2
0
 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));
 }
Example #3
0
 public UserLoginActor(ClusterNodeContext clusterContext, ActorBoundChannelRef channel, IPEndPoint clientRemoteEndPoint)
 {
     _logger           = LogManager.GetLogger($"UserLoginActor({clientRemoteEndPoint})");
     _clusterContext   = clusterContext;
     _channel          = channel;
     _isInternalAccess = clientRemoteEndPoint.Address == IPAddress.None;
 }
Example #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>();
 }
Example #5
0
 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>();
 }
Example #6
0
        public void Dispose()
        {
            if (Context == null)
            {
                return;
            }

            Context.System.Terminate();
            Context = null;
        }
Example #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
            });
        }
Example #8
0
        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);
        }
Example #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>();
        }
Example #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());
        }
Example #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;
        }
Example #12
0
 public UserActorTest(ITestOutputHelper output, ClusterContextFixture clusterContext)
     : base(output: output)
 {
     clusterContext.Initialize(Sys);
     _clusterContext = clusterContext.Context;
 }
Example #13
0
 public void Initialize(object[] args)
 {
     _clusterContext = (ClusterNodeContext)args[0];
 }
Example #14
0
 public BotWorker(ClusterNodeContext context, Config config)
 {
     _context = context;
 }
Example #15
0
 public UserTableWorker(ClusterNodeContext context, Config config)
 {
     _context = context;
 }