Adds relay, punchthrough, and port-forwarding support to the Unity NetworkClient More...
Public Member Functions | |
NobleClient (GeographicRegion region=GeographicRegion.AUTO, HostTopology topo=null, Action< string > onFatalError=null, int relayLifetime=60, int relayRefreshTime=30, float allocationResendTimeout=.1f, int maxAllocationResends=8) | |
Initialize the client using NobleConnectSettings. The region used is determined by the Relay Server Address in the NobleConnectSettings. More... | |
NobleClient (HostTopology topo=null) | |
Create a LAN only client More... | |
NobleClient (NetworkClient unetClient) | |
Create a NobleClient using an existing NetworkClient More... | |
NobleClient (string relayServerAddress, HostTopology topo=null, Action< string > onFatalError=null, int relayLifetime=60, int relayRefreshTime=30, float allocationResendTimeout=.1f, int maxAllocationResends=8) | |
Initialize the client using NobleConnectSettings but connect to specific relay server address. This method is useful for selecting the region to connect to at run time when starting the client. More... | |
void | PrepareToConnect () |
Prepare to connect but don't actually connect yet More... | |
void | Update () |
If you are using the NetworkClient directly you must call this method every frame. More... | |
void | Connect (string hostIP, ushort hostPort, bool isLANOnly=false) |
Connect to the provided host ip and port More... | |
void | Connect (IPEndPoint hostEndPoint, bool isLANOnly=false) |
Connect to the provided HostEndPoint More... | |
void | Shutdown () |
Shut down the client and clean everything up. More... | |
void | Dispose (bool disposing) |
Clean up and free resources. Called automatically when garbage collected. More... | |
void | Dispose () |
void | SetNetworkConnectionClass< T > () |
bool | Configure (ConnectionConfig config, int maxConnections) |
bool | Configure (HostTopology topology) |
bool | ReconnectToNewHost (string serverIp, int serverPort) |
bool | ReconnectToNewHost (EndPoint secureTunnelEndPoint) |
void | ConnectWithSimulator (string serverIp, int serverPort, int latency, float packetLoss) |
bool | Send (short msgType, MessageBase msg) |
bool | SendWriter (NetworkWriter writer, int channelId) |
bool | SendBytes (byte[] data, int numBytes, int channelId) |
bool | SendUnreliable (short msgType, MessageBase msg) |
bool | SendByChannel (short msgType, MessageBase msg, int channelId) |
void | SetMaxDelay (float seconds) |
void | GetStatsOut (out int numMsgs, out int numBufferedMsgs, out int numBytes, out int lastBufferedPerSecond) |
void | GetStatsIn (out int numMsgs, out int numBytes) |
Dictionary< short, NetworkConnection.PacketStat > | GetConnectionStats () |
void | ResetConnectionStats () |
int | GetRTT () |
void | RegisterHandler (short msgType, NetworkMessageDelegate handler) |
void | RegisterHandlerSafe (short msgType, NetworkMessageDelegate handler) |
void | UnregisterHandler (short msgType) |
Public Attributes | |
NetworkClient | unetClient |
The NetworkClient that will connect over the bridge to the relay More... | |
bool | isConnecting = false |
A convenient way to check if a connection is in progress More... | |
bool | ForceRelayOnly |
Store force relay so that we can pass it on to the iceController More... | |
Properties | |
ConnectionType | latestConnectionType [get, set] |
You can check this in OnClientConnect(), it will either be Direct, Punchthrough, or Relay. More... | |
static bool | active [get] |
string | serverIp [get] |
The rest of this is just a wrapper for UNET's NetworkClient. More... | |
int | serverPort [get] |
NetworkConnection | connection [get] |
Dictionary< short, NetworkMessageDelegate > | handlers [get] |
int | numChannels [get] |
HostTopology | hostTopology [get] |
bool? | isConnected [get] |
Type | networkConnectionClass [get] |
Adds relay, punchthrough, and port-forwarding support to the Unity NetworkClient
Use the Connect method to connect to a host.
NobleConnect.UNet.NobleClient.NobleClient | ( | GeographicRegion | region = GeographicRegion.AUTO , |
HostTopology | topo = null , |
||
Action< string > | onFatalError = null , |
||
int | relayLifetime = 60 , |
||
int | relayRefreshTime = 30 , |
||
float | allocationResendTimeout = .1f , |
||
int | maxAllocationResends = 8 |
||
) |
Initialize the client using NobleConnectSettings. The region used is determined by the Relay Server Address in the NobleConnectSettings.
The default address is connect.noblewhale.com, which will automatically select the closest server based on geographic region.
If you would like to connect to a specific region you can use one of the following urls:
us-east.connect.noblewhale.com - Eastern United States us-west.connect.noblewhale.com - Western United States eu.connect.noblewhale.com - Europe ap.connect.noblewhale.com - Asia-Pacific sa.connect.noblewhale.com - South Africa
Note that region selection will ensure each player connects to the closest relay server, but it does not prevent players from connecting across regions. If you want to prevent joining across regions you will need to implement that separately (by filtering out unwanted regions during matchmaking for example).
topo | The HostTopology to use for the NetworkClient. Must be the same on host and client. |
onFatalError | A method to call if something goes horribly wrong. |
allocationResendTimeout | Initial timeout before resending refresh messages. This is doubled for each failed resend. |
maxAllocationResends | 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. |
NobleConnect.UNet.NobleClient.NobleClient | ( | HostTopology | topo = null | ) |
Create a LAN only client
Clients created in this way will have no relay or punchthrough capabilities.
NobleConnect.UNet.NobleClient.NobleClient | ( | NetworkClient | unetClient | ) |
Create a NobleClient using an existing NetworkClient
This is used for the local client on hosts.
NobleConnect.UNet.NobleClient.NobleClient | ( | string | relayServerAddress, |
HostTopology | topo = null , |
||
Action< string > | onFatalError = null , |
||
int | relayLifetime = 60 , |
||
int | relayRefreshTime = 30 , |
||
float | allocationResendTimeout = .1f , |
||
int | maxAllocationResends = 8 |
||
) |
Initialize the client using NobleConnectSettings but connect to specific relay server address. This method is useful for selecting the region to connect to at run time when starting the client.
relayServerAddress | The url or ip of the relay server to connect to |
topo | The HostTopology to use for the NetworkClient. Must be the same on host and client. |
onFatalError | A method to call if something goes horribly wrong. |
allocationResendTimeout | Initial timeout before resending refresh messages. This is doubled for each failed resend. |
maxAllocationResends | 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. |
bool NobleConnect.UNet.NobleClient.Configure | ( | ConnectionConfig | config, |
int | maxConnections | ||
) |
bool NobleConnect.UNet.NobleClient.Configure | ( | HostTopology | topology | ) |
void NobleConnect.UNet.NobleClient.Connect | ( | IPEndPoint | hostEndPoint, |
bool | isLANOnly = false |
||
) |
Connect to the provided HostEndPoint
Note that the host address used here should be the one provided to the host by the relay server, not the actual ip of the host's computer. You can get this address on the host from Server.HostEndPoint.
hostEndPoint | The HostEndPoint of the server to connect to |
isLANOnly | Connect to LAN host address instead of using relays / punchthrough |
void NobleConnect.UNet.NobleClient.Connect | ( | string | hostIP, |
ushort | hostPort, | ||
bool | isLANOnly = false |
||
) |
Connect to the provided host ip and port
Note that the host address used here should be the one provided to the host by the relay server, not the actual ip of the host's computer. You can get this address on the host from Server.HostEndPoint.
hostIP | The IP of the server's HostEndPoint |
hostPort | The port of the server's HostEndPoint |
isLANOnly | Connect to LAN host address instead of using relays / punchthrough |
void NobleConnect.UNet.NobleClient.ConnectWithSimulator | ( | string | serverIp, |
int | serverPort, | ||
int | latency, | ||
float | packetLoss | ||
) |
void NobleConnect.UNet.NobleClient.Dispose | ( | ) |
void NobleConnect.UNet.NobleClient.Dispose | ( | bool | disposing | ) |
Clean up and free resources. Called automatically when garbage collected.
You shouldn't need to call this directly. It will be called automatically when an unused NobleClient is garbage collected or when shutting down the application.
disposing |
Dictionary<short, NetworkConnection.PacketStat> NobleConnect.UNet.NobleClient.GetConnectionStats | ( | ) |
int NobleConnect.UNet.NobleClient.GetRTT | ( | ) |
void NobleConnect.UNet.NobleClient.GetStatsIn | ( | out int | numMsgs, |
out int | numBytes | ||
) |
void NobleConnect.UNet.NobleClient.GetStatsOut | ( | out int | numMsgs, |
out int | numBufferedMsgs, | ||
out int | numBytes, | ||
out int | lastBufferedPerSecond | ||
) |
void NobleConnect.UNet.NobleClient.PrepareToConnect | ( | ) |
Prepare to connect but don't actually connect yet
This is used when initializing a client early before connecting. Getting this out of the way earlier can make the actual connection seem quicker.
bool NobleConnect.UNet.NobleClient.ReconnectToNewHost | ( | EndPoint | secureTunnelEndPoint | ) |
bool NobleConnect.UNet.NobleClient.ReconnectToNewHost | ( | string | serverIp, |
int | serverPort | ||
) |
void NobleConnect.UNet.NobleClient.RegisterHandler | ( | short | msgType, |
NetworkMessageDelegate | handler | ||
) |
void NobleConnect.UNet.NobleClient.RegisterHandlerSafe | ( | short | msgType, |
NetworkMessageDelegate | handler | ||
) |
void NobleConnect.UNet.NobleClient.ResetConnectionStats | ( | ) |
bool NobleConnect.UNet.NobleClient.Send | ( | short | msgType, |
MessageBase | msg | ||
) |
bool NobleConnect.UNet.NobleClient.SendByChannel | ( | short | msgType, |
MessageBase | msg, | ||
int | channelId | ||
) |
bool NobleConnect.UNet.NobleClient.SendBytes | ( | byte[] | data, |
int | numBytes, | ||
int | channelId | ||
) |
bool NobleConnect.UNet.NobleClient.SendUnreliable | ( | short | msgType, |
MessageBase | msg | ||
) |
bool NobleConnect.UNet.NobleClient.SendWriter | ( | NetworkWriter | writer, |
int | channelId | ||
) |
void NobleConnect.UNet.NobleClient.SetMaxDelay | ( | float | seconds | ) |
void NobleConnect.UNet.NobleClient.SetNetworkConnectionClass< T > | ( | ) |
T | : | NetworkConnection |
void NobleConnect.UNet.NobleClient.Shutdown | ( | ) |
Shut down the client and clean everything up.
You can call this method if you are totally done with a client and don't plan on using it to connect again.
void NobleConnect.UNet.NobleClient.UnregisterHandler | ( | short | msgType | ) |
void NobleConnect.UNet.NobleClient.Update | ( | ) |
If you are using the NetworkClient directly you must call this method every frame.
The NobleNetworkManager and NobleNetworkLobbyManager handle this for you but you if you are using the NobleClient directly you must make sure to call this method every frame.
bool NobleConnect.UNet.NobleClient.ForceRelayOnly |
Store force relay so that we can pass it on to the iceController
bool NobleConnect.UNet.NobleClient.isConnecting = false |
A convenient way to check if a connection is in progress
NetworkClient NobleConnect.UNet.NobleClient.unetClient |
The NetworkClient that will connect over the bridge to the relay
|
staticget |
|
get |
|
get |
|
get |
|
get |
|
getset |
You can check this in OnClientConnect(), it will either be Direct, Punchthrough, or Relay.
|
get |
|
get |
|
get |
The rest of this is just a wrapper for UNET's NetworkClient.
|
get |