package com.tokenplay.ue4.www.controllers;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.util.*;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.transaction.Transactional;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.vavr.control.Either;
import com.tokenplay.ue4.model.db.tables.records.*;
import com.tokenplay.ue4.www.api.*;
import com.tokenplay.ue4.www.exception.UserNotFoundException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.tuple.Triple;
import org.apache.logging.log4j.util.Strings;
import org.jooq.DSLContext;
import org.jooq.Record;
import org.jooq.Result;
import org.jooq.tools.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import com.hazelcast.core.HazelcastInstance;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
import com.tokenplay.ue4.configuration.HazelCastConfiguration;
import com.tokenplay.ue4.logic.TaskManager;
import com.tokenplay.ue4.model.db.tables.Tue4ServerAuthorised;
import com.tokenplay.ue4.model.db.tables.pojos.PaintScheme;
import com.tokenplay.ue4.model.db.tables.pojos.Server;
import com.tokenplay.ue4.model.repositories.ServersDB;
import com.tokenplay.ue4.steam.client.SteamApiClient;
import com.tokenplay.ue4.steam.client.types.ApiException;
import com.tokenplay.ue4.steam.client.types.api.AuthenticateUserTicketRS;
import com.tokenplay.ue4.steam.client.types.api.CheckAppOwnershipRS;
import com.tokenplay.ue4.steam.client.types.api.SteamApiSessionResponse;
import com.tokenplay.ue4.utils.BCrypt;
import com.tokenplay.ue4.www.caching.LiveServer;
import static io.vavr.control.Either.left;
import static io.vavr.control.Either.right;
import static org.springframework.util.StringUtils.isEmpty;
@Data
@EqualsAndHashCode(callSuper = false)
@Slf4j
@Controller
@Transactional
public class GameAPI extends CommonAPI {
private static final String DEVELOPMENT_KEYWORD = "serv6271@coolxeons";
public static final int NUM_RETRIES = 3;
@Autowired
DSLContext jooq;
@Autowired
HazelcastInstance hazelcast;
@Autowired(required = false)
SteamApiClient steamApiClient;
@ResponseBody
@RequestMapping(value = "/leave_server", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@Retryable(backoff = @Backoff(delay = 500))
public JSONResponse leaveServer(@RequestParam(value = "pil_token") String token, @RequestParam(value = "srv_id") String id, @RequestParam(
value = "quit", defaultValue = "false") boolean quitting) {
log.debug("Leave requested for token {} at server {}, quitting: {}", token, id, quitting);
JSONResponse response = new JSONResponse();
try {
PilotRecord pilot = TaskManager.leaveServer(getDataProvider(), token, id);
// If we are quitting, clean the pilot token as well
if (pilot == null) {
log.error("An unknown pilot with token {} tried to leave server {} or quit {}", token, id, quitting);
response.setError("Pilot session invalid");
} else if (quitting) {
getPilots().clean(pilot);
log.info("Pilot {} quit game", pilot.getPilCallsign());
}
} catch (Exception e) {
log.info("Error while {} was leaving server {}:{}", new Object[] {
token, id}, e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
response.setError("Error leaving server");
}
return response;
}
@ResponseBody
@RequestMapping(value = "/gi/{token}/rest/isdeveloper", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
@Retryable(backoff = @Backoff(delay = 500))
public JSONResponse isDeveloper(@PathVariable(value = "token") String token) {
JSONResponse response = new JSONResponse();
try {
Pair<PilotRecord, UsersRecord> pair = getPilots().findPilotAndUser(token);
UsersRecord user = null;
if (pair != null) {
user = pair.getRight();
}
if (getUsers().isDeveloper(user)) {
response.setSuccess(true);
}
} catch (Exception e) {
response.setError("Error finding developer.");
}
return response;
}
@ResponseBody
@RequestMapping(value = "/gi/rest/users/ext/{ext_service_id}/{ext_service_user_id}", produces = MediaType.APPLICATION_JSON_VALUE,
method = RequestMethod.GET)
@Retryable(backoff = @Backoff(delay = 500))
public JSONResponse getUserByExternalServiceId(@PathVariable(value = "ext_service_user_id") String extServiceUserId, @PathVariable(
value = "ext_service_id") String extServiceId, @RequestParam(value = "token") String token) {
JSONResponse response = new JSONResponse();
try {
if (isAuthorized(token)) {
ExternalService service = ExternalService.getEnum(extServiceId);
switch (service) {
case STEAM:
Either<UserNotFoundException, JSONResponse> stuff = toUserResponse(getPilots().findBySteamId(extServiceUserId));
if (stuff.isRight()) {
response = stuff.get();
response.setSuccess(true);
} else {
response.setSuccess(true);
log.info("Failed to find user for external service ID " + extServiceUserId);
}
break;
default:
String msg = "Unhandled external service " + extServiceId;
log.warn(msg);
response.setError(msg);
}
} else {
String msg = "Not authenticated";
log.warn(msg);
response.setError(msg);
}
} catch (IllegalArgumentException iae) {
String message = "Unknown external service ID: " + extServiceId;
log.error(message);
response.setError(message);
} catch (Exception e) {
String message = "Exception when finding user by external service ID " + extServiceUserId + " for service " + extServiceId;
log.error(message, e);
response.setError(message);
}
return response;
}
@ResponseBody
@RequestMapping(value = "/gi/rest/users/{user_id}", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
@Retryable(backoff = @Backoff(delay = 500))
public JSONResponse getUserByUserId(@PathVariable(value = "user_id") String userId, @RequestParam(value = "token") String token) {
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。毕业设计、课程设计源码文件,已经过测试可以直接使用。
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计&课设-基于Java的Epic Games后端系统-虚幻引擎4.zip (568个子文件)
bash_aliases 2KB
.classpath 1KB
bootstrap.min.css 115KB
jquery-ui.css 32KB
jquery-ui.min.css 28KB
bootstrap-theme.min.css 19KB
jquery.ui.theme.css 18KB
jquery.ui.theme.min.css 15KB
jquery.ui.datepicker.css 4KB
jquery.ui.datepicker.min.css 3KB
app.css 3KB
jquery.ui.button.css 2KB
jquery.ui.button.min.css 2KB
xeditable.css 2KB
jquery.ui.core.css 1KB
jquery.ui.menu.css 1KB
jquery.ui.tabs.css 1KB
jquery.ui.slider.css 1KB
jquery.ui.dialog.css 1KB
jquery.ui.menu.min.css 1KB
jquery.ui.resizable.css 1KB
jquery.ui.dialog.min.css 1KB
jquery.ui.slider.min.css 1KB
jquery.ui.spinner.css 1KB
jquery.ui.resizable.min.css 1KB
jquery.ui.core.min.css 1KB
jquery.ui.tabs.min.css 949B
jquery.ui.spinner.min.css 923B
jquery.ui.accordion.css 844B
security.css 830B
jquery.ui.base.css 782B
jquery.ui.accordion.min.css 716B
jquery.ui.progressbar.css 622B
jquery.ui.progressbar.min.css 508B
jquery.ui.tooltip.css 375B
jquery.ui.selectable.css 327B
jquery.ui.tooltip.min.css 322B
jquery.ui.autocomplete.css 321B
jquery.ui.all.css 292B
jquery.ui.selectable.min.css 220B
jquery.ui.autocomplete.min.css 211B
www.css 0B
glyphicons-halflings-regular.eot 20KB
animated-overlay.gif 2KB
animated-overlay.gif 2KB
_form.html 9KB
index.html 5KB
_form.html 4KB
serverbrowser.html 3KB
servers.html 3KB
list.html 2KB
list.html 2KB
_form.html 2KB
list.html 1KB
list.html 1KB
list.html 1KB
list.html 1KB
select_gamemaps.html 1KB
list.html 1KB
list.html 1KB
add.html 1KB
dirPagination.tpl.html 1KB
add.html 1KB
list.html 971B
list.html 883B
add.html 829B
list.html 812B
list.html 796B
add.html 782B
add.html 764B
add.html 762B
list.html 645B
list.html 632B
list.html 549B
list.html 547B
add.html 543B
add.html 537B
add.html 536B
add.html 520B
view.html 391B
edit.html 289B
add.html 192B
edit.html 185B
edit.html 179B
add.html 174B
add.html 168B
index.html 19B
GameAPI.java 95KB
Keys.java 51KB
Indexes.java 47KB
TaskManager.java 38KB
BCrypt.java 29KB
GearBayAPI.java 29KB
JOOQPilotsDB.java 22KB
UsersRecord.java 22KB
LoreGearsRecord.java 21KB
BlackMarketAPI.java 21KB
JOOQGearInstancesDB.java 20KB
ClientInterfaceAPI.java 19KB
PilotRecord.java 19KB
共 568 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
zy_zeros
- 粉丝: 953
- 资源: 320
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 驱动代码驱动代码驱动代码驱动代码
- SVID_20240523_141155_1.mp4
- Code for the complete guide to tkinter tutorial
- 关于百货中心供应链管理系统.zip
- SimpleFolderIcon-master 修改Unity的Project下的文件夹图标
- A python Tkinter widget to display tile based maps
- A pure Python library for adding tables to a Tkinter application
- Vector资源文件.zip
- MobaXterm-Installer
- 88-520告白(520气球).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功