Skip to content
This repository has been archived by the owner on Oct 20, 2021. It is now read-only.

Commit

Permalink
Change network connection types (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Balaji authored Nov 6, 2019
1 parent 6e4312a commit 4904e20
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 28 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@

## Unreleased

### Changed

- Changed the default client and simulated player network connection types to Modular UDP with compression enabled. [#238](https://github.com/spatialos/gdk-for-unity-fps-starter-project/pull/238)
- Changed the default `UnityGameLogic` and `SimulatedPlayerCoordinator` network connection types to TCP. [#238](https://github.com/spatialos/gdk-for-unity-fps-starter-project/pull/238)

## `0.2.10` - 2019-10-14

### Changed

- Upgraded to GDK for Unity version `0.2.10`

## `0.2.9` - 2019-09-16

### Changed

- Upgraded to GDK for Unity version `0.2.9`

## `0.2.8` - 2019-09-03

### Changed
Expand Down
2 changes: 1 addition & 1 deletion gdk.pinned
Original file line number Diff line number Diff line change
@@ -1 +1 @@
develop decea02869d2416431cb0660436579ad6ce7ad78
develop 1bc9acc488d9e4162bf35f19fb13998c5d9db6c2
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,19 @@ protected virtual string GetNonAuthPlayerPrefabPath()

protected override IConnectionHandlerBuilder GetConnectionHandlerBuilder()
{
var connectionParams = new ConnectionParameters
{
DefaultComponentVtable = new ComponentVtable(),
WorkerType = WorkerUtils.UnityClient
};

var builder = new SpatialOSConnectionHandlerBuilder()
.SetConnectionParameters(connectionParams);
IConnectionFlow connectionFlow;
var connectionParams = CreateConnectionParameters(WorkerUtils.UnityClient);
var workerId = CreateNewWorkerId(WorkerUtils.UnityClient);

if (UseSessionFlow)
{
connectionParams.Network.UseExternalIp = true;
builder.SetConnectionFlow(new ChosenDeploymentLocatorFlow(deployment,
new SessionConnectionFlowInitializer(new CommandLineConnectionFlowInitializer())));
connectionFlow = new ChosenDeploymentLocatorFlow(deployment,
new SessionConnectionFlowInitializer(new CommandLineConnectionFlowInitializer()));
}
else if (Application.isEditor)
{
builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityClient)));
connectionFlow = new ReceptionistFlow(workerId);
}
else
{
Expand All @@ -84,19 +79,20 @@ protected override IConnectionHandlerBuilder GetConnectionHandlerBuilder()
switch (initializer.GetConnectionService())
{
case ConnectionService.Receptionist:
builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityClient),
initializer));
connectionFlow = new ReceptionistFlow(workerId, initializer);
break;
case ConnectionService.Locator:
connectionParams.Network.UseExternalIp = true;
builder.SetConnectionFlow(new LocatorFlow(initializer));
connectionFlow = new LocatorFlow(initializer);
break;
default:
throw new ArgumentOutOfRangeException();
}
}

return builder;
return new SpatialOSConnectionHandlerBuilder()
.SetConnectionFlow(connectionFlow)
.SetConnectionParameters(connectionParams);
}

protected override void HandleWorkerConnectionEstablished()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Improbable.Gdk.Guns;
using Improbable.Gdk.Health;
using Improbable.Gdk.PlayerLifecycle;
using Improbable.Worker.CInterop;
using UnityEngine;

namespace Fps
Expand All @@ -20,20 +21,26 @@ protected override async void Start()

protected override IConnectionHandlerBuilder GetConnectionHandlerBuilder()
{
var builder = new SpatialOSConnectionHandlerBuilder()
.SetConnectionParameters(CreateConnectionParameters(WorkerUtils.UnityGameLogic));
IConnectionFlow connectionFlow;
ConnectionParameters connectionParameters;

var workerId = CreateNewWorkerId(WorkerUtils.UnityGameLogic);

if (Application.isEditor)
{
builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityGameLogic)));
connectionFlow = new ReceptionistFlow(workerId);
connectionParameters = CreateConnectionParameters(WorkerUtils.UnityGameLogic);
}
else
{
builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityGameLogic),
new CommandLineConnectionFlowInitializer()));
connectionFlow = new ReceptionistFlow(workerId, new CommandLineConnectionFlowInitializer());
connectionParameters = CreateConnectionParameters(WorkerUtils.UnityGameLogic,
new CommandLineConnectionParameterInitializer());
}

return builder;
return new SpatialOSConnectionHandlerBuilder()
.SetConnectionFlow(connectionFlow)
.SetConnectionParameters(connectionParameters);
}

protected override void HandleWorkerConnectionEstablished()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Improbable.Gdk.Core;
using Improbable.Gdk.Subscriptions;
using Improbable.Worker.CInterop;
using UnityEngine;
using Random = UnityEngine.Random;

Expand Down Expand Up @@ -59,21 +60,26 @@ protected override async void Start()

protected override IConnectionHandlerBuilder GetConnectionHandlerBuilder()
{
var builder = new SpatialOSConnectionHandlerBuilder()
.SetConnectionParameters(CreateConnectionParameters(WorkerUtils.SimulatedPlayerCoordinator));
IConnectionFlow connectionFlow;
ConnectionParameters connectionParameters;

var workerId = CreateNewWorkerId(WorkerUtils.SimulatedPlayerCoordinator);

if (Application.isEditor)
{
builder.SetConnectionFlow(new ReceptionistFlow(workerId));
connectionFlow = new ReceptionistFlow(workerId);
connectionParameters = CreateConnectionParameters(WorkerUtils.SimulatedPlayerCoordinator);
}
else
{
builder.SetConnectionFlow(new ReceptionistFlow(workerId, new CommandLineConnectionFlowInitializer()));
connectionFlow = new ReceptionistFlow(workerId, new CommandLineConnectionFlowInitializer());
connectionParameters = CreateConnectionParameters(WorkerUtils.SimulatedPlayerCoordinator,
new CommandLineConnectionParameterInitializer());
}

return builder;
return new SpatialOSConnectionHandlerBuilder()
.SetConnectionFlow(connectionFlow)
.SetConnectionParameters(connectionParameters);
}

protected override async void HandleWorkerConnectionEstablished()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public async Task ConnectSimulatedPlayer(string simulatedPlayerDevAuthToken,
{
var connectionParams = CreateConnectionParameters(WorkerUtils.UnityClient);
connectionParams.Network.UseExternalIp = true;
connectionParams.Network.ConnectionType = NetworkConnectionType.RakNet;

var builder = new SpatialOSConnectionHandlerBuilder()
.SetConnectionParameters(connectionParams)
Expand Down

0 comments on commit 4904e20

Please sign in to comment.