我正在尝试使用 Unity3d 游戏作为 GameList 客户端。
根据GameLift 论坛,亚马逊似乎不建议直接将游戏客户端用作 GameLift 客户端。
但我想试一试,因为我不想要一个单独的游戏服务。
第一步是从GitHub下载 AWS SDK 源代码并构建 .net35 版本的 dll;
将 AWSSDK.Core.dll 和 AWSSDK.GameLift.dll 放入 /Assets/Plugins;
从 MonoBehaviour 创建一个新的派生类来创建 AmazonGameLiftClient,下面是我的代码:
public class MyGameLiftClient : MonoBehaviour
{
private void Awake()
{
AmazonGameLiftConfig gameLiftConfig =
new AmazonGameLiftConfig {RegionEndpoint = RegionEndpoint.USWest1};
AmazonGameLiftClient client = new AmazonGameLiftClient(
"AwsAccessKeyId",
"AwsSecrectAcessKey",
gameLiftConfig);
}
}
这里我遇到了第一个问题:Failed to create the GameLiftClient
解决上述问题后,我尝试使用 AmazonGameLiftClient 列出车队:
AmazonGameLiftConfig gameLiftConfig = new AmazonGameLiftConfig {RegionEndpoint = RegionEndpoint.USWest1};
AmazonGameLiftClient client = new AmazonGameLiftClient(
"awsAccessKeyId",
"awsAccessSecretKey",
gameLiftConfig);
ListFleetsRequest listFleetsRequest = new ListFleetsRequest();
ListFleetsResponse fleets = client.ListFleets(listFleetsRequest);
但我得到以下异常:
NotSupportedException: https://gamelift.us-west-1.amazonaws.com/
System.Net.WebRequest.GetCreator (System.String prefix)
System.Net.WebRequest.Create (System.Uri requestUri)
Amazon.Runtime.Internal.HttpRequest..ctor (System.Uri requestUri)
Amazon.Runtime.Internal.HttpWebRequestFactory.CreateHttpRequest (System.Uri requestUri)
Amazon.Runtime.Internal.HttpHandler`1[System.IO.Stream].CreateWebRequest (IRequestContext requestContext)
Amazon.Runtime.Internal.HttpHandler`1[System.IO.Stream].InvokeSync (IExecutionContext executionContext)
Amazon.Runtime.Internal.PipelineHandler.InvokeSync (IExecutionContext executionContext)
Amazon.Runtime.Internal.Unmarshaller.InvokeSync (IExecutionContext executionContext)
Amazon.Runtime.Internal.PipelineHandler.InvokeSync (IExecutionContext executionContext)
Amazon.Runtime.Internal.ErrorHandler.InvokeSync (IExecutionContext executionContext)
- 我在我的 aws.config 中添加了更多配置来修复它,下面是我的整个 aws.config:
<configuration>
<configSections>
<section name="aws" type="Amazon.AWSSection, AWSSDK.Core"/>
<section name="system.diagnostics" type="System.Diagnostics.DiagnosticsConfigurationHandler" />
<sectionGroup name="system.net" type="System.Net.Configuration.NetSectionGroup, System">
<section name="authenticationModules" type="System.Net.Configuration.AuthenticationModulesSection, System" />
<section name="connectionManagement" type="System.Net.Configuration.ConnectionManagementSection, System" />
<sectionGroup name="mailSettings" type="System.Net.Configuration.MailSettingsSectionGroup, System">
<section name="smtp" type="System.Net.Configuration.SmtpSection, System" />
</sectionGroup>
<section name="requestCaching" type="System.Net.Configuration.RequestCachingSection, System" />
<section name="settings" type="System.Net.Configuration.SettingsSection, System" />
<section name="webRequestModules" type="System.Net.Configuration.WebRequestModulesSection, System" />
</sectionGroup>
</configSections>
<aws>
<logging logTo="Log4Net"/>
<csmConfig csmEnabled="false"/>
</aws>
<system.diagnostics>
<trace autoflush="true" />
</system.diagnostics>
<system.net>
<authenticationModules>
<add type="System.Net.DigestClient" />
<add type="System.Net.NegotiateClient" />
<add type="System.Net.KerberosClient" />
<add type="System.Net.NtlmClient" />
<add type="System.Net.BasicClient" />
</authenticationModules>
<connectionManagement>
<add address="*" maxconnection="2" />
</connectionManagement>
<webRequestModules>
<add prefix="http"
type="System.Net.HttpRequestCreator"
/>
<add prefix="https"
type="System.Net.HttpRequestCreator"
/>
<add prefix="file"
type="System.Net.FileWebRequestCreator"
/>
</webRequestModules>
</system.net>
</configuration>
- 现在我得到另一个例外:
MissingMethodException: Method not found: 'System.Net.ServicePoint.SetTcpKeepAlive'.
Amazon.Runtime.Internal.HttpHandler`1[System.IO.Stream].CreateWebRequest (IRequestContext requestContext)
Amazon.Runtime.Internal.HttpHandler`1[System.IO.Stream].InvokeSync (IExecutionContext executionContext)
Amazon.Runtime.Internal.PipelineHandler.InvokeSync (IExecutionContext executionContext)
Amazon.Runtime.Internal.Unmarshaller.InvokeSync (IExecutionContext executionContext)
Amazon.Runtime.Internal.PipelineHandler.InvokeSync (IExecutionContext executionContext)
Amazon.Runtime.Internal.ErrorHandler.InvokeSync (IExecutionContext executionContext)
有人知道这个例外吗?
我的环境:
- 操作系统:Mac OS X 10.14.1
- Unity3d:2018.2.12f1
- AWS 开发工具包核心:3.3.29.10(.net35)
- AWS 开发工具包 GameLift:3.3.12.29(.net35)