Exemplo n.º 1
0
 public TestGameEngine(IServer server, IDataContext dataContext, ILogger logger)
 {
     _server = server;
     _dataContext = dataContext;
     _logger = logger;
     _clients = new GetPriorityDictionary<int, IClient>();
     _requestHandlers = new RequestHandlerContainer(ResponseUserEvent, _clients, _dataContext);
     _isRunning = false;
 }
        public RequestHandlerContainer(EventHandler<ResponseDataEventArgs> requestCallBack, GetPriorityDictionary<int, IClient> clients, IDataContext dataContext)
        {
            _userEventsHandlers = new List<BaseRequestHandler>
            {
                { new UsersRequestHandler(PacketDataType.User, clients, dataContext) },
                { new ActionRequestHandler(PacketDataType.Action, clients, dataContext) },
                   { new PingRequestHandler(PacketDataType.Ping, clients, dataContext)}
            };

            foreach (var userEventsHandler in _userEventsHandlers)
            {
                userEventsHandler.OnResponseDataCallBack += requestCallBack;
            }

            if (_userEventsHandlers.Select(x => x.DataType).Distinct().Count() < _userEventsHandlers.Count)
            {
                throw new EngineException("Задано более одного обработчика запросов с одинаковым типом запроса!");
            }
        }
Exemplo n.º 3
0
 public UsersRequestHandler(PacketDataType dataType, GetPriorityDictionary<int, IClient> onlinePlayers, IDataContext dataContext)
     : base(dataType, onlinePlayers, dataContext)
 {
 }
Exemplo n.º 4
0
 public PingRequestHandler(PacketDataType dataType, GetPriorityDictionary<int, IClient> clients, IDataContext dataContext)
     : base(dataType, clients, dataContext)
 {
 }
Exemplo n.º 5
0
 protected BaseRequestHandler(PacketDataType dataType, GetPriorityDictionary<int, IClient> clients, IDataContext dataContext)
 {
     this.DataType = dataType;
     this.Clients = clients;
     this.DataContext = dataContext;
 }