Noble Connect
Add relays, punchthrough, and automatic port-forwarding to any networking system.
NobleNetworkManager Class Reference

A NetworkManager that utilizes the Noble Connect relay and punchthrough services More...

Public Member Functions

virtual void Awake ()
 Initialize connectionConfig and HostTopology plus some other important setup. More...
 
virtual void Update ()
 Updates the NobleClient and NobleServer. More...
 
new void StartClient ()
 Like NetworkManager.StartClient() but utilizes the Noble Connect relay and punchthrough services. More...
 
void StartClient (IPEndPoint hostEndPoint)
 Connect to a HostEndPoint, utilizing the Noble Connect relay and punchthrough services. More...
 
new void StopClient ()
 Stop the client. More...
 
override void OnStartServer ()
 Called when hosting starts. More...
 
virtual void OnFatalError ()
 Override this method to be informed when something goes horribly wrong. More...
 
override void OnStopServer ()
 Cleans up the server More...
 
override void OnServerConnect (NetworkConnection conn)
 Called when the server receives a client connection. More...
 
override void OnServerDisconnect (NetworkConnection conn)
 Called on the server when a client disconnects More...
 
virtual void OnServerPrepared (string hostAddress, ushort hostPort)
 Override this method to know when a Server has received their HostEndPoint More...
 

Public Attributes

new NobleClient client
 The NobleClient that will be used to connect to the host. More...
 
NobleServer server
 The NobleServer to use for hosting. More...
 

Protected Member Functions

virtual void OnDestroy ()
 Clean up the client and server. More...
 

Detailed Description

A NetworkManager that utilizes the Noble Connect relay and punchthrough services

This works almost exactly the same as the Unity NetworkManager. One difference though is that the host will not know the address that clients should connect to until it has been assigned by the Noble Connect servers. You can override the OnServerPrepared() method to know when this has happened and to get the hostAddress and hostPort (collectively known as the HostEndPoint) that clients should use to connect to the host. You can also get this address any time after it has been assigned via the server.HostEndPoint property.

Member Function Documentation

◆ Awake()

virtual void Awake ( )
inlinevirtual

Initialize connectionConfig and HostTopology plus some other important setup.

If you override this method you must call the base method or everything will explode.

◆ OnDestroy()

virtual void OnDestroy ( )
inlineprotectedvirtual

Clean up the client and server.

If you override this method you must call the base method or resources will not be properly cleaned up.

◆ OnFatalError()

virtual void OnFatalError ( )
inlinevirtual

Override this method to be informed when something goes horribly wrong.

You should see an error in your console with more info any time this is called. Generally it will either mean you've completely lost connection to the relay server or you have exceeded your CCU or bandwidth limit.

◆ OnServerConnect()

override void OnServerConnect ( NetworkConnection  conn)
inline

Called when the server receives a client connection.

If you override this method you must call the base method or everything will explode.

Parameters
connThe NetworkConnection of the connecting client

◆ OnServerDisconnect()

override void OnServerDisconnect ( NetworkConnection  conn)
inline

Called on the server when a client disconnects

If you override this method you must call the base method or resources will not be properly cleaned up.

Parameters
connThe NetworkConnection of the disconnecting client

◆ OnServerPrepared()

virtual void OnServerPrepared ( string  hostAddress,
ushort  hostPort 
)
inlinevirtual

Override this method to know when a Server has received their HostEndPoint

If you are using some sort matchmaking this is a good time to create a match now that you have the HostEndPoint that clients will need to connect to.

Parameters
hostAddressThe address of the HostEndPoint the clients should use when connecting to the host.
hostPortThe port of the HostEndPoint that clients should use when connecting to the host

◆ OnStartServer()

override void OnStartServer ( )
inline

Called when hosting starts.

If you override this method you must call the base method or everything will explode.

◆ OnStopServer()

override void OnStopServer ( )
inline

Cleans up the server

If you override this method you must call the base method or resources will not be properly cleaned up.

◆ StartClient() [1/2]

new void StartClient ( )
inline

Like NetworkManager.StartClient() but utilizes the Noble Connect relay and punchthrough services.

Just like UNet's StartClient(), this method uses the NetworkManager's networkAddress and networkPort, so make sure to set those to the host's HostEndPoint before calling this method.

◆ StartClient() [2/2]

void StartClient ( IPEndPoint  hostEndPoint)
inline

Connect to a HostEndPoint, utilizing the Noble Connect relay and punchthrough services.

◆ StopClient()

new void StopClient ( )
inline

Stop the client.

In most cases it is not recommended to call this method to disconnect the client as it will cause a timeout on the host. You should instead call client.connection.Disconenct() to send a disconnect message to the host and disconnect cleanly.

◆ Update()

virtual void Update ( )
inlinevirtual

Updates the NobleClient and NobleServer.

If you override this method you must call the base method or everything will explode.

Member Data Documentation

◆ client

new NobleClient client

The NobleClient that will be used to connect to the host.

◆ server

NobleServer server

The NobleServer to use for hosting.