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("Задано более одного обработчика запросов с одинаковым типом запроса!"); } }
public UsersRequestHandler(PacketDataType dataType, GetPriorityDictionary<int, IClient> onlinePlayers, IDataContext dataContext) : base(dataType, onlinePlayers, dataContext) { }
public PingRequestHandler(PacketDataType dataType, GetPriorityDictionary<int, IClient> clients, IDataContext dataContext) : base(dataType, clients, dataContext) { }
protected BaseRequestHandler(PacketDataType dataType, GetPriorityDictionary<int, IClient> clients, IDataContext dataContext) { this.DataType = dataType; this.Clients = clients; this.DataContext = dataContext; }