/// <summary>Called when hosting starts.</summary> /// <remarks> /// If you override this method you must call the base method or everything will explode. /// </remarks> override public void OnStartServer() { base.OnStartServer(); if (!isLANOnly) { try { NobleServer.relayLifetime = relayLifetime; NobleServer.maxAllocationResends = maxRelayRefreshAttempts; NobleServer.allocationResendTimeout = relayRefreshTimeout; NobleServer.relayRefreshTime = relayRefreshTime; ushort port = NobleServer.GetTransportPort(); NobleServer.InitializeHosting(port, region, OnServerPrepared, OnFatalError, forceRelayConnection); return; } catch (SocketException) { isLANOnly = true; Logger.Log("Failed to resolve relay server address. Starting in LAN only mode", Logger.Level.Warn); } } // If we made it to here then either this is a LAN only host or Noble Connect failed. // Start in LAN only mode. OnStartServerLANOnly(); }
public void OnStartServerLANOnly() { IPAddress localIP = GetALANAddress(); networkPort = NobleServer.GetTransportPort(); networkAddress = localIP.ToString(); NobleServer.HostEndPoint = new IPEndPoint(localIP, networkPort); OnServerPrepared(localIP.ToString(), (ushort)networkPort); }