Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

[Standalone UNET Relay] MLAPI.Relay

Discussion in 'Connected Games' started by TwoTen, Jun 13, 2018.

  1. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,000

    Hello!

    I have created a UNET standalone relay that I want to share with you.

    Issues & Support
    Bugs should be reported on the GitHub Issue Tracker. Questions can be asked on this thread or in the MLAPI Discord server.

    Compatibility
    The relay is tested on the HLAPI and the MLAPI but works on all UNET projects. The Relay requires .NET Core to be installed on the target machine.

    Usage
    Using the relay is really straight forward. First, download the RelayTransport class.
    Then replace NetworkTransport with RelayTransport everywhere where these methods are used:
    • Connect
    • ConnectEndPoint
    • ConnectWithSimulator
    • AddHost
    • AddHostWithSimulator
    • AddWebsocketHost
    • Disconnect
    • Send
    • QueueMessageForSending
    • SendQueuedMessages
    • Receive
    • ReceiveFromHost
    Example: NetworkTransport.Connect(signatureGoesHere) => RelayTransport.Connect(sameSignature);


    Even if you do this, you can still use connect without relay by setting the RelayTransport.Enabled to false. Setting the RelayTransport.Enabled to false will make the relay transport act exactly like the NetworkTransport with no changes.
    And that's it!

    I really hope you find this useful. More documentation about configuration etc and the RelayTransport class can be found on GitHub. Note that the RelayTransport class is open source and is licenced as "public domain". For the exact licence. See the licence file. This licence is for the RelayTransport only and does not cover the Relay itself, any documentation or external libraries.


    GitHub
     
    Last edited: Aug 7, 2018
  2. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    248
  3. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,000
  4. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,000
  5. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,000
    Jos-Yule likes this.
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    3,026
    It looks like if your game currently uses Unity's relay service, that this is probably the most viable solution to keep your game running if you intend to keep it alive after Unity shuts down their relays in a few years.
     
  7. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,000
    Yea, now that it's open source it will be free with no limits. Since it's so easy to actually enable (not much code change), it should make a switch super smooth. The only thing that might be a bit offputting is the licence. It's AGPL, meaning if you change the code and use it in some way (even self host), you have to publish your source. (Ex via PR or fork)
     
    Last edited: Aug 8, 2018
  8. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,000
    Actually, after rethinking my choice of licence, I realized that AGPL was a mistake. It has been switched to GPL. This is to allow private modified versions of the software which is useful for things like custom authentication. I always want the licence to encourage creativity and collaboration, not be a limiting factor of what you can do.

    However, the RelayTransport will continue to be public domain.
     
  9. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    248
    Hey, this is great, thanks for doing this!
     
  10. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    90