/// <summary> /// Sets up internal network client. /// </summary> public void Start(int port = 0) { _peerConfig = NetworkSettings.GetNetPeerConfig(this); _peerConfig.Port = port > 0 ? port : _peerConfig.Port; _netClient = new NetClient(_peerConfig); _peer = _netClient; _netClient.Start(); IsRunning = true; }
/// <summary> /// Starts the server. /// </summary> /// <param name="port">The port number to host on.</param> public void Start(int port = 0) { _peerConfig = NetworkSettings.GetNetPeerConfig(this); _peerConfig.Port = port > 0 ? port : _peerConfig.Port; if (_authenticationRequired) { _peerConfig.EnableMessageType(NetIncomingMessageType.ConnectionApproval); } Port = port; Address = _peerConfig.BroadcastAddress.ToString(); _netServer = new NetServer(_peerConfig); _peer = _netServer; SteamGameServer.LogOnAnonymous(); Logger.Trace($"NetworkServer starting at {Address}:{Port}"); try { _netServer.Start(); IsRunning = true; Logger.Trace("NetworkServer started."); IsRunning = true; } catch (SocketException e) { Logger.Warn("NetworkServer threw an exception while starting."); Logger.Warn(e.Message); } }