Code Monkey home page Code Monkey logo

nodelistserver-example's Introduction

NodeListServer Example Project

Ko-Fi PayPal MIT Licensed

Please consider a donation (see the Ko-Fi button above) if this project is useful to you.

This repository contains a Unity 2020.3 LTS project that demostrates a implementation of a classic Server Browser (one you'd see in classic games such as Battlefield 1942, old Call of Duty games, etc).

It is advised that this project is only used as a reference, don't expect it to be feature rich.

While the Server Browser logic is network stack agnostic (as in, it doesn't care if you're using Mirror, Mirage, a fishy-named network library or something paid), the Mirror and Mirage integrations are dependent on the respective network stacks and require further steps. To help keep dependencies to a minimum the mentioned network stacks are not included in the repository.

Requirements

Setup

  1. You can either clone this repository and open it in your version of Unity, please note that any versions below Unity 2020 LTS are unsupported and I cannot have 50 different Unity versions on my workstation. Alternatively, download a snapshot archive of this repository and copy the NodeLS Client directory into your project's Assets directory.
  2. If you use Unity Assembly Definitions, add a reference to the NodeLS.Client Definition. This will allow you to access the NodeListServer namespace.
  3. You're good to go! You can now create class instances of the NodeLS Client. An example would be NLSCommunicator myCommunicator = new NLSCommunicator();.

Review the Communicator.cs as it's commented and does explain what it's trying to do.

Testing with DebugCommunicator

  • There is a DebugCommunicator script that I used during development to ensure things are operating correctly. It uses three keys which are Q, W and E.
  • Q sends a request to retrieve the server list, W fakes a server registration request and E removes the fake server that it created (if it was successful).
  • You'll need to modify the Endpoint in which it uses for it to work on your setup. This script has a compile define to only be available inside the Unity Editor. It will not be compiled in standalone builds.
  • Using this script outside of a testing environment is a bad idea. You've been warned.

Integration Packages

  • Some integrations exist for various network stacks as mentioned earlier.
  • Look inside the NodeLS Client Integrations folder for a UnityPackage file that contains scripts for use with the network stack the integration is for.
  • Note that some integrations may be cause a compile error or warning about things being obsolete over time. If this happens, please open a issue ticket.

Wait, why I cannot connect to a listed server?

The easy answers...

  • The server died. It happens, as it's Unity Engine after all.
  • The server port is closed or needs Port Forwarding. If the server is on your ISP connection, open that port in your router: read the manual to figure out how to do that. See the footnote for additional info.

The more technicial answers...

Are you trying to connect a server hosted on your network using the Server Browser?

  • Unless your NodeLS instance is inside your local network, NodeLS will detect your public IP address. Your private IP might be 10.0.0.2, but your public IP might be 42.69.4.20.
  • Most routers may not support loop-back connections, which is basically a LAN connection calling the external outside IP address.
  • Some ISPs block game server traffic. Comcast, Verizon and Vodafone are some that do traffic blocking, including servers on non-business grade connections. You're screwed if your ISP does that to you.
  • Hosting servers behind a VPN connection is a bad idea.
  • Mobile connections will not work for server hosting. Due to the nature of how mobile internet works, even if it does work partially, if you drop signal then you're in the dark.

Footnote: Keep in mind some ISPs can disallow port forwarding for stupid reasons, or they'll penalize you for doing so. If it's on a Windows/Linux cloud instance, open the firewall using Windows Firewall or iptables, although if you're using Google Cloud/Amazon AWS/Microsoft Azure then it can be a clusterfuck.

I need help!

  • Open a issue ticket, although I expect you to know the absolute basics of C# and Unity Engine first.
  • Don't be shy asking for help, but please give details as to what you tried, and what went wrong.

Credits

  • AnthonyE
  • JesusLuvsYooh
  • NodeLS users & contributors
  • Coffee donators
  • Mirror discord

Thanks for using Australian Open Source Software!

nodelistserver-example's People

Contributors

jesusluvsyooh avatar kr4xkan avatar softwareguy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nodelistserver-example's Issues

An error occurs when start the server.

There's an error when start the server, please see the log:

Initialize engine version: 2018.4.1f1 (b7c424a951c0)
Forcing GfxDevice: Null
GfxDevice: creating device client; threaded=0
NullGfxDevice:
Version: NULL 1.0 [1.0]
Renderer: Null Device
Vendor: Unity Technologies
Begin MonoManager ReloadAssembly

  • Completed reload, in 0.072 seconds
    UnloadTime: 0.434400 ms
    TelepathyTransport initialized!

(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)

Server: Start port=7777

(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)

Server: listening port=7777

(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)

Unloading 4 Unused Serialized files (Serialized files now loaded: 0)
Refreshing the server list...

(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)

Working...

(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)

UnloadTime: 30.965200 ms
Multiple NetworkManagers detected in the scene. Only one NetworkManager can exist at a time. The duplicate NetworkManager will be destroyed.

(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)

TelepathyTransport initialized!

(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)

Unloading 38 unused Assets to reduce memory usage. Loaded Objects now: 569.
Total: 1.801700 ms (FindLiveObjects: 0.120300 ms CreateObjectMapping: 0.011500 ms MarkObjects: 1.643700 ms DeleteObjects: 0.026000 ms)

NodeLS: Mission failed. We'll get them next time.
An error occurred while registering the server. One or more required fields, like the server GUID, name and port might be missing. You will need to fix this and call RegisterServer again to retry.

(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)

Cannot connect to destination host

(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)

NodeLS: But it's not over yet. Get ready for the next round: retrying as an update as specified.

(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)

NodeLS: Mission failed. We'll get them next time.
An error occurred while updating the server information. The communication key or the server GUID might be wrong, or some other information is bogus. Or it could be you are experiencing connection problems.

(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)

NodeLS: But it's not over yet, get ready for the next round. Retrying update as registration.

(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 45)

Adjustments to the example.

Hide the address, port, password variables on NodeListServer NetMan gameobject.
Logic gameobject variables are the ones that need to change, and it can be confusing.

Get list works fine.
Pressing host or start server from the HUD, breaks the example.
Having this work, and add games onto the list should be the next step.
The example might need to be adjusted to match upto latest NLS changes, Update was removed in favour of Add, for example.

Missing script

I couldnt find the "NodeListServerNetMan.cs" file anywhere in the project. Can you tell me where i can find it?

Screenshot 2022-03-02 104435

Is it possible to create room hosts that are not server?

I'm having a problem right now when I create a room with a mobile device (and create a host at the same time) and find that it doesn't perform well enough, so I'm wondering if there's a solution where it doesn't act as a host when creating the room so I can have the PC device used as a server.

Cannot stop NodeLIstServer in Unity Editor.

After I start list server in Unity Editor, the NodeListServer instance show "New server added: 'FractalServer' from ::ffff:127.0.0.1. UUID: 'ecb4d255-fbc8-4c4d-81a5-52e093bbf3ca'", then I stop server in Unity Editor, the NodeListServer instance show nothing , and restart it in unity editor, there will be an error occurs, please see the log:

NodeLS: Mission failed. We'll get them next time.
An error occurred while registering the server. One or more required fields, like the server GUID, name and port might be missing. You will need to fix this and call RegisterServer again to retry.
UnityEngine.Debug:LogError(Object)
d__43:MoveNext() (at Assets/NodeListServer/NodeListServerNetManager.cs:356)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

HTTP/1.1 400 Bad Request
UnityEngine.Debug:LogError(Object)
d__43:MoveNext() (at Assets/NodeListServer/NodeListServerNetManager.cs:359)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.