private Davinet.PeerDebug.Settings NetworkDebug() { var debug = new Davinet.PeerDebug.Settings() { simulateLatency = simulateLatency.isOn, simulatePacketLoss = simulatePacketLoss.isOn, maxLatency = Convert.ToInt32(latencyMax.text), minLatency = Convert.ToInt32(latencyMin.text), packetLossChance = Mathf.RoundToInt(packetLossPercent.value * 100) }; return(debug); }
public void StartServer(int port, PeerDebug.Settings debugSettings = null) { StatefulWorld.Instance.Initialize(); PeerDebug debug = null; if (debugSettings != null) { debug = gameObject.AddComponent <PeerDebug>(); debug.Initialize(debugSettings); } Server = new Server(defaultPeerSettings, debug); Server.Listen(port); Server.OnPeerConnected += Server_OnPeerConnected; OnServerListen?.Invoke(); }
public void ConnectClient(string address, int port, PeerDebug.Settings debugSettings = null) { if (server == null) { StatefulWorld.Instance.Initialize(authorityArbiter); } PeerDebug debug = null; if (debugSettings != null && server == null) { debug = gameObject.AddComponent <PeerDebug>(); debug.Initialize(debugSettings); } client = new Peer(defaultPeerSettings, debug); client.OnReceivePeerId += OnReceivePeerId; client.Connect(address, port, server != null); if (server != null) { server.HasListenClient = true; } }