public override async Task <StartGameEarlyResponse> StartGameEarly(StartGameEarlyRequest request, ServerCallContext context) { DbUserModel dbUserModel = context.UserState["user"] as DbUserModel; if (dbUserModel == null) { return new StartGameEarlyResponse() { Status = ResponseFactory.createResponse(ResponseType.UNAUTHORIZED) } } ; Room room = await Room.GetRoomFromGuid(request.RoomId); if (room == null) { return new StartGameEarlyResponse() { Status = ResponseFactory.createResponse(ResponseType.ROOM_DOES_NOT_EXIST) } } ; if (room.GameConfiguration.Creator.Id == dbUserModel.UserModel.Id) { return(new StartGameEarlyResponse() { Status = await room.StartGame(), }); } return(new StartGameEarlyResponse() { Status = ResponseFactory.createResponse(ResponseType.PERMISSION_DENIED), }); }
public override async Task <StartGameEarlyResponse> StartGameEarly(StartGameEarlyRequest request, ServerCallContext context) { RedisUserModel user = context.UserState["user"] as RedisUserModel; if (user == null) { return new StartGameEarlyResponse() { Status = ResponseFactory.createResponse(ResponseType.UNAUTHORIZED) } } ; RedisRoomModel room = await RedisRoomModel.GetRoomFromGuid(request.RoomId); if (room == null) { return new StartGameEarlyResponse() { Status = ResponseFactory.createResponse(ResponseType.ROOM_DOES_NOT_EXIST) } } ; if (room.RoomModel.CreatorId == user.UserModel.Id) { return(new StartGameEarlyResponse() { Status = await room.StartGame(), }); } return(new StartGameEarlyResponse() { Status = ResponseFactory.createResponse(ResponseType.PERMISSION_DENIED), }); }