Esempio n. 1
0
    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);
    }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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;
            }
        }