public IActionResult Index([FromBody] GameEventRequest request, string appId) { var okResponse = new OkResponse(); _logger.LogInformation($"{Request.GetUri()} - {JsonConvert.SerializeObject(okResponse)}"); return(Ok(okResponse)); }
public dynamic Post(GameEventRequest request, string appId) { if (log.IsDebugEnabled) log.DebugFormat("{0} - {1}", Request.RequestUri, JsonConvert.SerializeObject(request)); var okResponse = new OkResponse(); if (log.IsDebugEnabled) log.Debug(JsonConvert.SerializeObject(okResponse)); return okResponse; }
public dynamic Post(GameEventRequest request, string appId) { if (log.IsDebugEnabled) { log.DebugFormat("{0} - {1}", Request.RequestUri, JsonConvert.SerializeObject(request)); } var okResponse = new OkResponse(); if (log.IsDebugEnabled) { log.Debug(JsonConvert.SerializeObject(okResponse)); } return(okResponse); }
private GameEventModel toGameEventModel(RedisUserModel requestor, GameEventRequest request) { Guid eventId; eventId = Guid.NewGuid(); return(new GameEventModel() { EventId = eventId.ToString(), UnixTimeIssued = DateTime.UtcNow.ToFileTimeUtc(), IssuedBy = requestor.UserModel.Id, OccursAtTick = request.OccursAtTick, EventData = request.EventData, }); }
public async Task <SubmitGameEventResponse> AddPlayerGameEvent(DbUserModel player, GameEventRequest request) { GameEventModel eventModel = toGameEventModel(player, request); // Ensure the event happens after current time. GameTick currentTick = new GameTick(DateTime.FromFileTimeUtc(GameConfiguration.UnixTimeStarted), DateTime.UtcNow); if (eventModel.OccursAtTick <= currentTick.GetTick()) { return(new SubmitGameEventResponse() { Status = ResponseFactory.createResponse(ResponseType.INVALID_REQUEST), });; } // TODO: validate event. await MongoConnector.GetGameEventCollection().InsertOneAsync(new GameEventModelMapper(eventModel)); return(new SubmitGameEventResponse() { Status = ResponseFactory.createResponse(ResponseType.SUCCESS), EventId = eventModel.Id, }); }
public async Task <SubmitGameEventResponse> AddPlayerGameEvent(RedisUserModel player, GameEventRequest request) { GameEventModel eventModel = toGameEventModel(player, request); // Ensure the event happens after current time. GameTick currentTick = new GameTick(DateTime.FromFileTimeUtc(RoomModel.UnixTimeStarted), DateTime.UtcNow); if (eventModel.OccursAtTick <= currentTick.GetTick()) { return(new SubmitGameEventResponse() { Status = ResponseFactory.createResponse(ResponseType.INVALID_REQUEST), });; } // TODO: validate event. HashEntry[] entries = new[] { new HashEntry(eventModel.EventId, eventModel.ToByteArray()), }; await RedisConnector.Redis.HashSetAsync(GameEventsKey(), entries); await RedisConnector.Redis.SetAddAsync(UserGameEventsKey(player), eventModel.EventId); return(new SubmitGameEventResponse() { Status = ResponseFactory.createResponse(ResponseType.SUCCESS), EventId = eventModel.EventId, }); }