Inherits NetworkManager.
Inherited by NobleConnect.Mirror.NobleRoomManager.
Public Member Functions | |
override void | Awake () |
Initialize connectionConfig and HostTopology plus some other important setup. More... | |
override void | Start () |
virtual void | Update () |
Updates the NobleClient and NobleServer. More... | |
void | InitClient () |
Initialize the NobleClient and allocate a relay. 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... | |
void | StartClientLANOnly () |
Start a client in LAN only mode. No relays or punchthrough will be used. More... | |
void | StartClientLANOnly (IPEndPoint hostEndPoint) |
Start a client in LAN only mode. No relays or punchthrough will be used. More... | |
override void | OnStartClient () |
virtual new void | StartHost () |
Start hosting, connect a local client, and request a HostEndPoint from the NobleConnectServices More... | |
void | StartHostLANOnly () |
Start hosting, connect a local client, but do no create a relay or enable punchthrough More... | |
new void | StartServer () |
Start a server and request a HostEndPoint from the NobleConnectServices More... | |
void | StartServerLANonly () |
Start a server, but do no create a relay or enable punchthrough More... | |
new void | StopClient () |
Stop the client. More... | |
void | RegisterClientHandlers () |
Register default client message handlers More... | |
override void | OnStartServer () |
Called when hosting starts. More... | |
void | OnStartServerLANOnly () |
IPAddress | GetALANAddress () |
virtual void | OnFatalError (string error) |
Override this method to be informed when something goes horribly wrong. More... | |
override void | OnStopServer () |
Cleans up the server More... | |
override void | OnStopClient () |
override void | OnServerConnect (NetworkConnection conn) |
Called when the server receives a client connection. More... | |
override void | OnClientDisconnect (NetworkConnection conn) |
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... | |
override void | OnDestroy () |
Clean up the client and server. More... | |
Public Attributes | |
NobleClient | client |
The NobleClient that will be used to connect to the host. More... | |
int | networkPort |
GeographicRegion | region = GeographicRegion.AUTO |
The geographic region to use when selecting a relay server. More... | |
bool | forceRelayConnection |
You can enable this to force relay connections to be used for testing purposes. More... | |
NobleConnect.Logger.Level | logLevel = NobleConnect.Logger.Level.Info |
How much output do you want to see? More... | |
float | requestTimeout = .2f |
Request timeout. More... | |
int | relayRefreshTime = 30 |
How often to send relay refresh requests, in seconds. More... | |
float | relayRefreshTimeout = .1f |
Initial timeout before resending refresh messages. This is doubled for each failed resend. More... | |
int | maxRelayRefreshAttempts = 3 |
Max number of times to try and resend refresh messages before giving up and shutting down the relay connection. More... | |
int | relayLifetime = 30 |
How long a relay will stay alive without being refreshed (in seconds) More... | |
Action< NetworkConnection > | onClientConnectInternal |
We need a reference to Mirror's internal connect method but it is not public so we get it via reflection. More... | |
Action< NetworkConnection > | onClientDisconnectInternal |
We need a reference to Mirror's internal disconnect method but it is not public so we get it via reflection. More... | |
Action< NetworkConnection > | onServerConnectInternal |
We need a reference to Mirror's internal connect method but it is not public so we get it via reflection. More... | |
Action< NetworkConnection > | onServerDisconnectInternal |
We need a reference to Mirror's internal disconnect method but it is not public so we get it via reflection. More... | |
bool | isDisconnecting |
True when in the middle of disconnecting More... | |
Protected Attributes | |
bool | isLANOnly |
If the current connection is LAN only More... | |
Properties | |
IPEndPoint | HostEndPoint [get] |
This is the address that clients should connect to. It is assigned by the relay server. More... | |
override void NobleConnect.Mirror.NobleNetworkManager.Awake | ( | ) |
Initialize connectionConfig and HostTopology plus some other important setup.
If you override this method you must call the base method or everything will explode.
IPAddress NobleConnect.Mirror.NobleNetworkManager.GetALANAddress | ( | ) |
void NobleConnect.Mirror.NobleNetworkManager.InitClient | ( | ) |
Initialize the NobleClient and allocate a relay.
You can call as soon as you know that the player intends to connect to host or even as soon as your game is launched. Initializing takes a few seconds, so doing it early can make connections seem quicker. If you do not call this method it will be called for you when you try and connect.
override void NobleConnect.Mirror.NobleNetworkManager.OnClientDisconnect | ( | NetworkConnection | conn | ) |
override void NobleConnect.Mirror.NobleNetworkManager.OnDestroy | ( | ) |
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.
|
virtual |
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.
override void NobleConnect.Mirror.NobleNetworkManager.OnServerConnect | ( | NetworkConnection | conn | ) |
Called when the server receives a client connection.
If you override this method you must call the base method or everything will explode.
conn | The NetworkConnection of the connecting client |
override void NobleConnect.Mirror.NobleNetworkManager.OnServerDisconnect | ( | NetworkConnection | conn | ) |
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.
conn | The NetworkConnection of the disconnecting client |
|
virtual |
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.
hostAddress | The address of the HostEndPoint the clients should use when connecting to the host. |
hostPort | The port of the HostEndPoint that clients should use when connecting to the host |
override void NobleConnect.Mirror.NobleNetworkManager.OnStartClient | ( | ) |
override void NobleConnect.Mirror.NobleNetworkManager.OnStartServer | ( | ) |
Called when hosting starts.
If you override this method you must call the base method or everything will explode.
void NobleConnect.Mirror.NobleNetworkManager.OnStartServerLANOnly | ( | ) |
override void NobleConnect.Mirror.NobleNetworkManager.OnStopClient | ( | ) |
override void NobleConnect.Mirror.NobleNetworkManager.OnStopServer | ( | ) |
Cleans up the server
If you override this method you must call the base method or resources will not be properly cleaned up.
void NobleConnect.Mirror.NobleNetworkManager.RegisterClientHandlers | ( | ) |
Register default client message handlers
override void NobleConnect.Mirror.NobleNetworkManager.Start | ( | ) |
new void NobleConnect.Mirror.NobleNetworkManager.StartClient | ( | ) |
Like NetworkManager.StartClient() but utilizes the Noble Connect relay and punchthrough services.
Just like Mirror'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.
void NobleConnect.Mirror.NobleNetworkManager.StartClient | ( | IPEndPoint | hostEndPoint | ) |
Connect to a HostEndPoint, utilizing the Noble Connect relay and punchthrough services.
void NobleConnect.Mirror.NobleNetworkManager.StartClientLANOnly | ( | ) |
Start a client in LAN only mode. No relays or punchthrough will be used.
You will need the host's LAN ip to connect using this method. Just like Mirror's StartClient(), this method uses the NetworkManager's networkAddress and networkPort, so make sure to set those to the host's LAN ip before calling this method.
void NobleConnect.Mirror.NobleNetworkManager.StartClientLANOnly | ( | IPEndPoint | hostEndPoint | ) |
Start a client in LAN only mode. No relays or punchthrough will be used.
You will need the host's LAN ip to connect using this method.
hostEndPoint |
|
virtual |
Start hosting, connect a local client, and request a HostEndPoint from the NobleConnectServices
OnServerPrepared will be called when the HostEndPoint has been retrieved and the host is ready to receive relay / punchthrough connections.
void NobleConnect.Mirror.NobleNetworkManager.StartHostLANOnly | ( | ) |
Start hosting, connect a local client, but do no create a relay or enable punchthrough
new void NobleConnect.Mirror.NobleNetworkManager.StartServer | ( | ) |
Start a server and request a HostEndPoint from the NobleConnectServices
OnServerPrepared will be called when the HostEndPoint has been retrieved and the host is ready to receive relay / punchthrough connections.
void NobleConnect.Mirror.NobleNetworkManager.StartServerLANonly | ( | ) |
Start a server, but do no create a relay or enable punchthrough
OnServerPrepared will be called immediately and passed the local LAN address that clients can use to connect.
new void NobleConnect.Mirror.NobleNetworkManager.StopClient | ( | ) |
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.
|
virtual |
Updates the NobleClient and NobleServer.
If you override this method you must call the base method or everything will explode.
NobleClient NobleConnect.Mirror.NobleNetworkManager.client |
The NobleClient that will be used to connect to the host.
bool NobleConnect.Mirror.NobleNetworkManager.forceRelayConnection |
You can enable this to force relay connections to be used for testing purposes.
Disables punchthrough and direct connections. Forces connections to use the relays. This is useful if you want to test your game with the unavoidable latency that is introduced when the relay servers are used. Note that you will tend to use more bandwidth on the relay servers while this is enabled than you typically would.
bool NobleConnect.Mirror.NobleNetworkManager.isDisconnecting |
True when in the middle of disconnecting
Disconnecting is asynchronous so that the disconnect message gets a chance to get sent out before the network connection is disposed. This will be set to true when the disconnect message is sent out and will remain true until the network connection is disposed.
|
protected |
If the current connection is LAN only
NobleConnect.Logger.Level NobleConnect.Mirror.NobleNetworkManager.logLevel = NobleConnect.Logger.Level.Info |
How much output do you want to see?
int NobleConnect.Mirror.NobleNetworkManager.maxRelayRefreshAttempts = 3 |
Max number of times to try and resend refresh messages before giving up and shutting down the relay connection.
If refresh messages fail for 30 seconds the relay connection will be closed remotely regardless of these settings.
int NobleConnect.Mirror.NobleNetworkManager.networkPort |
Action<NetworkConnection> NobleConnect.Mirror.NobleNetworkManager.onClientConnectInternal |
Action<NetworkConnection> NobleConnect.Mirror.NobleNetworkManager.onClientDisconnectInternal |
Action<NetworkConnection> NobleConnect.Mirror.NobleNetworkManager.onServerConnectInternal |
Action<NetworkConnection> NobleConnect.Mirror.NobleNetworkManager.onServerDisconnectInternal |
GeographicRegion NobleConnect.Mirror.NobleNetworkManager.region = GeographicRegion.AUTO |
The geographic region to use when selecting a relay server.
Defaults to AUTO which will automatically select the closest region. This is useful if you would like your players to be able to choose their region at run time. Note that players are not prevented from connecting across regions. That would need to be implementing separately via matchmaking for example, by filtering out matches from undesired regions.
int NobleConnect.Mirror.NobleNetworkManager.relayLifetime = 30 |
How long a relay will stay alive without being refreshed (in seconds)
Setting this value higher means relays will stay alive longer even if the host temporarily loses connection or otherwise fails to send the refresh request in time. This can be helpful to maintain connection on an undependable network or when heavy application load (such as loading large levels synchronously) temporarily prevents requests from being processed. The drawback is that CCU is used for as long as the relay stays alive, so players that crash or otherwise don't clean up properly can cause lingering CCU usage for up to relayLifetime seconds.
int NobleConnect.Mirror.NobleNetworkManager.relayRefreshTime = 30 |
How often to send relay refresh requests, in seconds.
float NobleConnect.Mirror.NobleNetworkManager.relayRefreshTimeout = .1f |
Initial timeout before resending refresh messages. This is doubled for each failed resend.
float NobleConnect.Mirror.NobleNetworkManager.requestTimeout = .2f |
Request timeout.
This effects how long to wait before considering a request to have failed. Requests are used during the punchthrough process and for setting up and maintaining relays. If you are allowing cross-region play or expect high latency you can increase this so that requests won't time out. The drawback is that waiting longer for timeouts causes it take take longer to detect actual failed requests so the connection process may take longer.
|
get |
This is the address that clients should connect to. It is assigned by the relay server.
Note that this is not the host's actual IP address, but one assigned to the host by the relay server. When clients connect to this address, Noble Connect will find the best possible connection and use it. This means that the client may actually end up connecting to an address on the local network, or an address on the router, or an address on the relay. But you don't need to worry about any of that, it is all handled for you internally.