Skip to content

feat: Unity Transport + Relay #887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 78 commits into from
Sep 13, 2021
Merged

Conversation

cdmazom
Copy link
Contributor

@cdmazom cdmazom commented Jun 5, 2021

This PR adds support for using the Unity Transport package as a transport for MLAPI.

wackoisgod and others added 12 commits May 27, 2021 17:39
wip still waiting on some packages to be published.
updating UTP to preview 5 with Relay ping support
fixing issue with endpoint
Some cleanup
In order to use Relay for this transport you need to install the package into your project its no longer a dependcy
@cdmazom cdmazom changed the title Feature: UTP Transport + Relay feat: UTP Transport + Relay Jun 5, 2021
* update to relay sdk v0.0.1-preview.5
* remove workarounds
  - use byte array representation of allocation id
  - connection data truncation is not longer needed
  - set default relay endpoint as production
* updated auth to v0.5.0
  - updated core and authentication versions
  - updated relay version (compatible with latest core)
  - updated authentication calls
@unity-cla-assistant
Copy link

unity-cla-assistant commented Jun 17, 2021

CLA assistant check
All committers have signed the CLA.

Jura-Z and others added 11 commits June 22, 2021 06:50
C# Guid convertion to byte array is not compatbile with relay, intead we can use the byte array provided by the relay sdk
MLAPI appears to expect Connect events on servers when new clients
connect (at least this is what's implemented in SIPTransport). UTP
doesn't generate Connect events server-side, so we must generate them
ourselves when accepting connections.
* Add some basic UTPTranport tests

* Implement OnDestroy in UTPTransport

The implementation is the same as Shutdown, meaning it only disposes of
the driver (if not already disposed of). The driver (!) for this change
is to avoid leaking resources when tests fail.

* Add connection tests for UTPTransport

* Add basic data transmission tests for UTPTransport
* Correctly handle empty messages in Send

The UTPTransport.Send method would throw a NullReferenceException
exception when passed default(ArraySegment<byte>) as the message data.
Now it simply sends an empty message to its remote host (not a terribly
useful feature, but better than an exception).

* Make it possible to receive messages >1024 bytes

The fragmentation pipeline was set up to handle messages up to 6KB in
length, but the receive buffer was only 1KB long. Messages longer than
that were just ignored (although an error message was logged).

* Add proper support for channels in UTPTransport

The transport now selects an appropriate pipeline according to the
delivery level of the channel, rather than send everything on the
default unreliable pipeline.
* DST-528: Extracted Relay SDK calls out of UTP adapter for MLAPI; it now accepts a variable passed in via a setter method. Also updated the sample test project included to illustrate these changes.

* DST-528: Made some changes that address feedback comments; mainly restructured the manner that code external to UTPTransport passes in the requisite relay server data so that external code doesn't need to know about the internal data structures that UTPTransport uses.

* DST-528: Removing minor changes that were erroneously left in when taking other approaches.
Comment on lines 1 to 2
m_EditorVersion: 2020.3.12f1
m_EditorVersionWithRevision: 2020.3.12f1 (b3b2c6512326)
m_EditorVersion: 2020.3.15f2
m_EditorVersionWithRevision: 2020.3.15f2 (6cf78cb77498)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean personally I think the project should always be on the latest version of the LTS :P but that is just me. which would be .18 :P I me right now with PR triggers we aren't even testing on 2020.3 which I find also wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nightly runs on various platforms and versions at least, but yeah 2020.3 baseline for PRs might be more useful, I'm not sure

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well seeing as how its the min version for the package it should run on it :P I mean for UTP we run on 2020.3/2021.2/trunk across all desktop platforms for PRs because more often then I would like to admit stuff breaks across unity versions. I think we should at least make sure PRs work with the min version.

Comment on lines -675 to +684
projectName:
organizationId:
projectName: relay-stg
organizationId: relay-stg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, those values are for the cloud services related stuff since we did add relay testing to the project. So for internal testing that is what they need to be, if public devs want to mess around with things this value will automatically get updated with their services info when they login to their services uDash. So for us yes its required.


InitDriver();

if (m_Driver.Bind(NetworkEndPoint.AnyIpv4) != 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is IPv6 supported by the adapter? If so, might want to choose between this and AnyIpv6 depending on the address family of serverEndpoint.

Alternatively, I don't think there's any need to bind on the client side. Could remove this entirely.

Copy link
Contributor

@andrews-unity andrews-unity Sep 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do support IPv6 in the transport but I don't think we support it currently in the adapter.

As for binding the protocol can bind which in this case we use for Relay

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add a ticket to support IPV6 to the transport API in general.

Connected,
}

public const int MaximumMessageLength = 6 * 1024;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where this number is coming from?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boss Room :( It is still configurable in the serialized field.

Copy link
Contributor

@0xFA11 0xFA11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some naming nits but apart from that, looks good to me!
(UTP -> UnityTransport & NGO -> Netcode)

@0xFA11 0xFA11 changed the title feat: UTP Transport + Relay feat: Unity Transport + Relay Sep 13, 2021
@andrews-unity andrews-unity enabled auto-merge (squash) September 13, 2021 17:50
@andrews-unity andrews-unity merged commit a02dfee into develop Sep 13, 2021
@andrews-unity andrews-unity deleted the feature/initial-relay-utp branch September 13, 2021 18:20
SamuelBellomo added a commit that referenced this pull request Sep 16, 2021
…nsform

* develop:
  feat: NetworkBehaviour.IsSpawned  (#1190)
  feat: added tip to the network manager inspector that directs to install tools (MTT-1211) (#1182)
  refactor!: remove network dictionary & set, use native container in List, add tests (#1149)
  fix: Fixed remote disconnects not properly cleaning up (#1184)
  test: base changes to PR-1114 (#1165)
  test: verify do not destroy networkobjects on networkmanager shutdown (#1183)
  chore: removal of EnableNetworkVariable in NetworkConfig. It's always True now (#1179)
  fix: Fix DontDestroyWithOwner not returning ownership (#1181)
  test: Giving Android some more room as the connection tests are timing sensitive (#1178)
  fix: unitytransport connectionmode buttons (#1176)
  test: added min frames to multi-instance helper (#1170)
  chore: Add mobile tests to nightly trigger (#1161)
  feat: snapshot spawn pre-requisite (#1166)
  feat: Unity Transport + Relay (#887)
  feat: client scene synchronization mode (#1171)

# Conflicts:
#	testproject/Assets/Scenes/SampleScene.unity
mollstam pushed a commit to Keepsake-Games/com.unity.netcode.gameobjects that referenced this pull request Feb 13, 2023
* Adding support for UTP/Unity Relay in Netcode for GameObjects

Co-authored-by: Andrew Spiering <aspiering@gmail.com>
Co-authored-by: Andrew Spiering <andrews@unity3d.com>
Co-authored-by: Fernando Galandrini <fernando.galandrini@gmail.com>
Co-authored-by: Iurii Zakipnyi <jura.zakipniy@gmail.com>
Co-authored-by: Fernando Galandrini <fernando.galandrini@unity3d.com>
Co-authored-by: Simon Lemay <simon.lemay@unity3d.com>
Co-authored-by: thoward-unity <87874023+thoward-unity@users.noreply.github.com>
Co-authored-by: Cosmin <cosmin.bararu@unity3d.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.