Adds relay and punchthrough support to the Unity NetworkServer More...
Static Public Member Functions | |
static void | InitializeHosting (int listenPort, GeographicRegion region=GeographicRegion.AUTO, HostTopology topo=null, Action< string, ushort > onPrepared=null, Action< string > onFatalError=null, bool forceRelayOnly=false) |
Initialize the server using NobleConnectSettings. The region used is determined by the Relay Server Address in the NobleConnectSettings. More... | |
static void | InitializeHosting (int listenPort, string relayServerAddress, HostTopology topo=null, Action< string, ushort > onPrepared=null, Action< string > onFatalError=null, bool forceRelayOnly=false) |
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... | |
static void | _Init (int listenPort, string relayServerAddress, HostTopology topo=null, Action< string, ushort > onPrepared=null, Action< string > onFatalError=null, bool forceRelayOnly=false) |
Initialize the NetworkServer and Ice.Controller More... | |
static void | Update () |
If you are using the NetworkServer directly you must call this method every frame. More... | |
static void | Listen (int port=0, GeographicRegion region=GeographicRegion.AUTO, HostTopology topo=null, Action< string, ushort > onPrepared=null, Action< string > onFatalError=null, bool forceRelayOnly=false) |
Start listening for incoming connections More... | |
static void | RegisterHandler (short msgType, NetworkMessageDelegate handler) |
Register a handler for a particular message type. More... | |
static void | UnregisterHandler (short msgType) |
static void | ClearHandlers () |
static void | Dispose () |
Clean up and free resources. Called automatically when garbage collected. More... | |
static void | OnServerConnect (NetworkConnection conn) |
static void | OnServerDisconnect (NetworkConnection conn) |
static void | SetNetworkConnectionClass< T > () |
static bool | Configure (ConnectionConfig config, int maxConnections) |
static bool | Configure (HostTopology topology) |
static void | Reset () |
static void | Shutdown () |
static NetworkClient | BecomeHost (NetworkClient oldClient, int port, MatchInfo matchInfo, int oldConnectionId, PeerInfoMessage[] peers) |
static bool | SendToAll (short msgType, MessageBase msg) |
static bool | SendToReady (GameObject contextObj, short msgType, MessageBase msg) |
static void | SendWriterToReady (GameObject contextObj, NetworkWriter writer, int channelId) |
static void | SendBytesToReady (GameObject contextObj, byte[] buffer, int numBytes, int channelId) |
static void | SendBytesToPlayer (GameObject player, byte[] buffer, int numBytes, int channelId) |
static bool | SendUnreliableToAll (short msgType, MessageBase msg) |
static bool | SendUnreliableToReady (GameObject contextObj, short msgType, MessageBase msg) |
static bool | SendByChannelToAll (short msgType, MessageBase msg, int channelId) |
static bool | SendByChannelToReady (GameObject contextObj, short msgType, MessageBase msg, int channelId) |
static void | DisconnectAll () |
static void | ClearSpawners () |
static void | GetStatsOut (out int numMsgs, out int numBufferedMsgs, out int numBytes, out int lastBufferedPerSecond) |
static void | GetStatsIn (out int numMsgs, out int numBytes) |
static void | SendToClientOfPlayer (GameObject player, short msgType, MessageBase msg) |
static void | SendToClient (int connectionId, short msgType, MessageBase msg) |
static bool | ReplacePlayerForConnection (NetworkConnection conn, GameObject player, short playerControllerId, NetworkHash128 assetId) |
static bool | ReplacePlayerForConnection (NetworkConnection conn, GameObject player, short playerControllerId) |
static bool | AddPlayerForConnection (NetworkConnection conn, GameObject player, short playerControllerId, NetworkHash128 assetId) |
static bool | AddPlayerForConnection (NetworkConnection conn, GameObject player, short playerControllerId) |
static void | SetClientReady (NetworkConnection conn) |
static void | SetAllClientsNotReady () |
static void | SetClientNotReady (NetworkConnection conn) |
static void | DestroyPlayersForConnection (NetworkConnection conn) |
static void | ClearLocalObjects () |
static void | Spawn (GameObject obj) |
static bool | SpawnWithClientAuthority (GameObject obj, GameObject player) |
static bool | SpawnWithClientAuthority (GameObject obj, NetworkConnection conn) |
static bool | SpawnWithClientAuthority (GameObject obj, NetworkHash128 assetId, NetworkConnection conn) |
static void | Spawn (GameObject obj, NetworkHash128 assetId) |
static void | Destroy (GameObject obj) |
static void | UnSpawn (GameObject obj) |
static GameObject | FindLocalObject (NetworkInstanceId netId) |
static Dictionary< short, NetworkConnection.PacketStat > | GetConnectionStats () |
static void | ResetConnectionStats () |
static bool | AddExternalConnection (NetworkConnection conn) |
static void | RemoveExternalConnection (int connectionId) |
static bool | SpawnObjects () |
Static Public Attributes | |
static float | allocationResendTimeout = .1f |
Initial timeout before resending refresh messages. This is doubled for each failed resend. More... | |
static int | maxAllocationResends = 8 |
Max number of times to try and resend refresh messages before giving up and shutting down the relay connection. More... | |
static int | relayLifetime = 60 |
How long a relay will stay alive without being refreshed (in seconds) More... | |
static int | relayRefreshTime = 30 |
How often to refresh the relay to keep it alive, in seconds More... | |
Properties | |
static IPEndPoint | HostEndPoint [get, set] |
This is the address that clients should connect to. It is assigned by the relay server. More... | |
static List< NetworkConnection > | localConnections [get] |
static int | listenPort [get] |
static int | serverHostId [get] |
static ReadOnlyCollection< NetworkConnection > | connections [get] |
static Dictionary< short, NetworkMessageDelegate > | handlers [get] |
static HostTopology | hostTopology [get] |
static Dictionary< NetworkInstanceId, NetworkIdentity > | objects [get] |
static bool | dontListen [get, set] |
static bool | useWebSockets [get, set] |
static bool | active [get] |
static bool | localClientActive [get] |
static int | numChannels [get] |
static float | maxDelay [get, set] |
static Type | networkConnectionClass [get] |
Adds relay and punchthrough support to the Unity NetworkServer
Use the Listen method to start listening for incoming connections.
|
static |
Initialize the NetworkServer and Ice.Controller
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
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 NobleServer is garbage collected or when shutting down the application.
disposing |
|
static |
|
static |
|
static |
|
static |
|
static |
Initialize the server using NobleConnectSettings. The region used is determined by the Relay Server Address in the NobleConnectSettings.
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. |
|
static |
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. |
onPrepared | A method to call when the host has received their HostEndPoint from the relay server. |
onFatalError | A method to call if something goes horribly wrong. |
|
static |
Start listening for incoming connections
port | |
onPrepared | A method to call when the host has received their HostEndPoint from the relay server. |
|
static |
|
static |
|
static |
Register a handler for a particular message type.
There are several system message types which you can add handlers for. You can also add your own message types.
msgType | Message type number. |
handler | Function handler which will be invoked for when this message type is received. |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
T | : | NetworkConnection |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
If you are using the NetworkServer directly you must call this method every frame.
The NobleNetworkManager and NobleNetworkLobbyManager handle this for you but you if you are using the NobleServer directly you must make sure to call this method every frame.
|
static |
Initial timeout before resending refresh messages. This is doubled for each failed resend.
|
static |
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.
|
static |
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.
|
static |
How often to refresh the relay to keep it alive, in seconds
|
staticget |
|
staticget |
|
staticgetset |
|
staticget |
|
staticgetset |
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.
|
staticget |
|
staticget |
|
staticget |
|
staticget |
|
staticgetset |
|
staticget |
|
staticget |
|
staticget |
|
staticget |
|
staticgetset |