Skip to content

Commit

Permalink
Merge pull request #3 from aliyun/v1.0.x
Browse files Browse the repository at this point in the history
feat:consoleAdmin & multiplay & live
  • Loading branch information
xfslove authored Nov 24, 2022
2 parents 072a9c6 + e8c9945 commit 305d881
Show file tree
Hide file tree
Showing 118 changed files with 13,411 additions and 193 deletions.
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ Add this dependency to your project's POM:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>alibabacloud-yjopenapi-java-client</artifactId>
<version>1.0.20221015-beta</version>
<version>1.0.20221125</version>
</dependency>

or
<!-- independent -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>alibabacloud-yjopenapi-java-client</artifactId>
<version>1.0.20221015-beta</version>
<version>1.0.20221125</version>
<classifier>shaded</classifier>
<exclusions>
<exclusion>
Expand Down Expand Up @@ -72,11 +72,37 @@ try {

| Api | Method | Params | Result | Description |
| ------------ | ------------- | ------------- | ------------- | ------------- |
| *ConsoleAdminApi* | **adaptGameVersion** | *adaptGameVersionForms* | *ConsoleAdminAdaptGameVersionResult* | 发起游戏版本适配 |
| *ConsoleAdminApi* | **addGameToProject** | *addGameToProjectForms* | *ConsoleAdminAddGameToProjectResult* | 将游戏添加到项目 |
| *ConsoleAdminApi* | **createGame** | *createGameForms* | *ConsoleAdminCreateGameResult* | 创建游戏 |
| *ConsoleAdminApi* | **createProject** | *createProjectForms* | *ConsoleAdminCreateProjectResult* | 创建项目 |
| *ConsoleAdminApi* | **deleteGame** | *deleteGameForms* | *ConsoleAdminDeleteGameResult* | 删除指定的游戏 |
| *ConsoleAdminApi* | **deleteGameVersion** | *deleteGameVersionForms* | *ConsoleAdminDeleteGameVersionResult* | 发起游戏版本适配 |
| *ConsoleAdminApi* | **deleteProject** | *deleteProjectForms* | *ConsoleAdminDeleteProjectResult* | 删除指定的项目 |
| *ConsoleAdminApi* | **getGameVersion** | *getGameVersionForms* | *ConsoleAdminGetGameVersionResult* | 获取单个游戏版本信息 |
| *ConsoleAdminApi* | **getGameVersionProgress** | *getGameVersionProgressForms* | *ConsoleAdminGetGameVersionProgressResult* | 查询版本处理进度(包含上传、适配、部署) |
| *ConsoleAdminApi* | **listDeployableInstances** | *listDeployableInstancesForms* | *ConsoleAdminListDeployableInstancesResult* | 指定项目和游戏版本,获取可以部署的实例 |
| *ConsoleAdminApi* | **listGameVersions** | *listGameVersionsForms* | *ConsoleAdminListGameVersionsResult* | 分页获取游戏版本列表 |
| *ConsoleAdminApi* | **listGames** | *listGamesForms* | *ConsoleAdminListGamesResult* | 分页获取游戏列表 |
| *ConsoleAdminApi* | **listProjects** | *listProjectsForms* | *ConsoleAdminListProjectsResult* | 分页获取项目列表 |
| *ConsoleAdminApi* | **removeGameFromProject** | *removeGameFromProjectForms* | *ConsoleAdminRemoveGameFromProjectResult* | 将游戏移出项目 |
| *ConsoleAdminApi* | **submitDeployment** | *submitDeploymentForms* | *ConsoleAdminSubmitDeploymentResult* | 提交游戏版本的部署请求 |
| *ConsoleAdminApi* | **uploadGameVersionByDownload** | *uploadGameVersionByDownloadForms* | *ConsoleAdminUploadGameVersionByDownloadResult* | 一键上传:文件上传接口,用远程下载的方式生成新版本 |
| *DispatchApi* | **batchStopGame** | *batchStopGameForms* | *BatchStopGameResult* | 游戏下全量踢下线,异步接口 |
| *DispatchApi* | **getGameConcurrency** | *getGameConcurrencyForms* | *GetGameConcurrencyResult* | 调用GetGameConcurrency获取游戏当前并发数 |
| *DispatchApi* | **getStock** | *getStockForms* | *GetStockResult* | 调用GetStock获取游戏当前库存 |
| *DispatchApi* | **getStopGameToken** | *getStopGameTokenForms* | *GetStopGameTokenResult* | 全量踢下线获取token |
| *DispatchApi* | **stopGame** | *stopGameForms* | *StopGameResult* | 服务端发起,停止某个用户的某个游戏的某个会话 |
| *DispatchApi* | **tryToGetSlot** | *tryToGetSlotForms* | *TryToGetSlotResult* | 为用户调度分配游戏容器,容器一旦分配成功会被锁住,一段时间内不再分配给其他用户,过期释放。 |
| *LiveApi* | **queryStatus** | *queryStatusForms* | *LiveQueryStatusResult* | 查询推流状态 |
| *LiveApi* | **startGameLive** | *startGameLiveForms* | *LiveStartGameLiveResult* | 开始直播推流 |
| *LiveApi* | **stopGameLive** | *stopGameLiveForms* | *LiveStopGameLiveResult* | 结束直播推流 |
| *MultiplayApi* | **close** | *closeForms* | *MultiplayCloseResult* | 关闭联机 |
| *MultiplayApi* | **init** | *initForms* | *MultiplayInitResult* | 初始化联机 |
| *MultiplayApi* | **join** | *joinForms* | *MultiplayJoinResult* | 加入联机 |
| *MultiplayApi* | **leave** | *leaveForms* | *MultiplayLeaveResult* | 离开联机 |
| *MultiplayApi* | **modify** | *modifyForms* | *MultiplayModifyResult* | 修改联机 |
| *MultiplayApi* | **query** | *queryForms* | *MultiplayQueryResult* | 离开联机 |
| *TokenApi* | **getTriple** | | *GetTripleResult* | 获取临时安全令牌 |

## License
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>alibabacloud-yjopenapi-java-client</artifactId>
<packaging>jar</packaging>
<name>alibabacloud-yjopenapi-java-client</name>
<version>1.0.20221015-beta</version>
<version>1.0.20221125</version>
<url>https://github.com/aliyun/alibabacloud-yjopenapi-java-client</url>
<description>YuanJing OpenAPI SDK for Java</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
*
* YuanJing OpenAPI SDK
*
* OpenAPI spec version: 1.0.20221015-beta
*
*/

package com.alibaba.yjopenapi.client.api;
Expand Down
142 changes: 0 additions & 142 deletions src/main/java/com/alibaba/yjopenapi/client/api/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
*
* YuanJing OpenAPI SDK
*
* OpenAPI spec version: 1.0.20221015-beta
*
*/

package com.alibaba.yjopenapi.client.api;
Expand All @@ -18,14 +16,7 @@
import java.io.UnsupportedEncodingException;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
Expand All @@ -46,10 +37,6 @@ public class ApiClient {

private Map<String, String> defaultHeaderMap = new HashMap<String, String>();

private InputStream sslCaCert;
private boolean verifyingSsl;
private KeyManager[] keyManagers;

private OkHttpClient httpClient;

/*
Expand All @@ -58,8 +45,6 @@ public class ApiClient {
public ApiClient() {
httpClient = new OkHttpClient();

verifyingSsl = true;

}

/**
Expand Down Expand Up @@ -102,68 +87,6 @@ public ApiClient setHttpClient(OkHttpClient httpClient) {
return this;
}

/**
* True if isVerifyingSsl flag is on
*
* @return True if isVerifySsl flag is on
*/
public boolean isVerifyingSsl() {
return verifyingSsl;
}

/**
* Configure whether to verify certificate and hostname when making https requests.
* Default to true.
* NOTE: Do NOT set to false in production code, otherwise you would face multiple types of cryptographic attacks.
*
* @param verifyingSsl True to verify TLS/SSL connection
* @return ApiClient
*/
public ApiClient setVerifyingSsl(boolean verifyingSsl) {
this.verifyingSsl = verifyingSsl;
applySslSettings();
return this;
}

/**
* Get SSL CA cert.
*
* @return Input stream to the SSL CA cert
*/
public InputStream getSslCaCert() {
return sslCaCert;
}

/**
* Configure the CA certificate to be trusted when making https requests.
* Use null to reset to default.
*
* @param sslCaCert input stream for SSL CA cert
* @return ApiClient
*/
public ApiClient setSslCaCert(InputStream sslCaCert) {
this.sslCaCert = sslCaCert;
applySslSettings();
return this;
}

public KeyManager[] getKeyManagers() {
return keyManagers;
}

/**
* Configure client keys to use for authorization in an SSL session.
* Use null to reset to default.
*
* @param managers The KeyManagers to use
* @return ApiClient
*/
public ApiClient setKeyManagers(KeyManager[] managers) {
this.keyManagers = managers;
applySslSettings();
return this;
}

/**
* Add a default header.
*
Expand Down Expand Up @@ -732,71 +655,6 @@ public RequestBody buildRequestBodyFormEncoding(Map<String, Object> formParams)
return formBuilder.build();
}

/**
* Apply SSL related settings to httpClient according to the current values of
* verifyingSsl and sslCaCert.
*/
private void applySslSettings() {
try {
TrustManager[] trustManagers = null;
HostnameVerifier hostnameVerifier = null;
if (!verifyingSsl) {
TrustManager trustAll = new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
@Override
public X509Certificate[] getAcceptedIssuers() { return null; }
};
SSLContext sslContext = SSLContext.getInstance("TLS");
trustManagers = new TrustManager[]{ trustAll };
hostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) { return true; }
};
} else if (sslCaCert != null) {
// Any password will work.
char[] password = null;
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
Collection<? extends Certificate> certificates = certificateFactory.generateCertificates(sslCaCert);
if (certificates.isEmpty()) {
throw new IllegalArgumentException("expected non-empty set of trusted certificates");
}
KeyStore caKeyStore = newEmptyKeyStore(password);
int index = 0;
for (Certificate certificate : certificates) {
String certificateAlias = "ca" + Integer.toString(index++);
caKeyStore.setCertificateEntry(certificateAlias, certificate);
}
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(caKeyStore);
trustManagers = trustManagerFactory.getTrustManagers();
}

if (keyManagers != null || trustManagers != null) {
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(keyManagers, trustManagers, new SecureRandom());
httpClient.setSslSocketFactory(sslContext.getSocketFactory());
} else {
httpClient.setSslSocketFactory(null);
}
httpClient.setHostnameVerifier(hostnameVerifier);
} catch (GeneralSecurityException e) {
throw new RuntimeException(e);
}
}

private KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException {
try {
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, password);
return keyStore;
} catch (IOException e) {
throw new AssertionError(e);
}
}

private static String join(List<String> array, String separator) {
if (array == null || array.isEmpty()) {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
*
* YuanJing OpenAPI SDK
*
* OpenAPI spec version: 1.0.20221015-beta
*
*/

package com.alibaba.yjopenapi.client.api;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
*
* YuanJing OpenAPI SDK
*
* OpenAPI spec version: 1.0.20221015-beta
*
*/

package com.alibaba.yjopenapi.client.api;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
*
* YuanJing OpenAPI SDK
*
* OpenAPI spec version: 1.0.20221015-beta
*
*/

package com.alibaba.yjopenapi.client.api;
Expand Down
Loading

0 comments on commit 305d881

Please sign in to comment.