예제 #1
0
파일: Peer.cs 프로젝트: tuita520/Davinet
        public Peer(Settings settings, PeerDebug debug) : this(settings)
        {
            this.debug = debug;

            if (debug != null)
            {
                netManager.SimulatePacketLoss         = debug.settings.simulatePacketLoss;
                netManager.SimulationPacketLossChance = debug.settings.packetLossChance;
            }
        }
예제 #2
0
파일: Network.cs 프로젝트: tuita520/Davinet
        public void StartServer(int port, PeerDebug.Settings debugSettings = null)
        {
            StatefulWorld.Instance.Initialize(authorityArbiter);

            PeerDebug debug = null;

            if (debugSettings != null)
            {
                debug = gameObject.AddComponent <PeerDebug>();
                debug.Initialize(debugSettings);
            }

            server = new Peer(defaultPeerSettings, debug);
            server.OnReceivePeerId += OnReceivePeerId;
            server.Listen(port);

            server.OnPeerConnected += Server_OnPeerConnected;
        }
예제 #3
0
        public void ConnectClient(string address, int port, PeerDebug.Settings debugSettings = null)
        {
            if (Server == null)
            {
                StatefulWorld.Instance.Initialize();
            }

            PeerDebug debug = null;

            if (debugSettings != null && Server == null)
            {
                debug = gameObject.AddComponent <PeerDebug>();
                debug.Initialize(debugSettings);
            }

            Client = new Client(defaultPeerSettings, debug);
            Client.Connect(address, port, Server != null);
        }
예제 #4
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();
        }
예제 #5
0
        public Peer(PeerDebug debug)
        {
            this.debug = debug;

            listener = new EventBasedNetListener();
            listener.NetworkReceiveEvent    += Listener_NetworkReceiveEvent;
            listener.ConnectionRequestEvent += Listener_ConnectionRequestEvent;

            netManager             = new NetManager(listener);
            netManager.AutoRecycle = false;

            if (debug != null)
            {
                netManager.SimulatePacketLoss         = debug.settings.simulatePacketLoss;
                netManager.SimulationPacketLossChance = debug.settings.packetLossChance;
            }

            netDataWriter = new NetDataWriter();

            queuedStatePackets = new Queue <NetPacketReader>();
        }
예제 #6
0
파일: Network.cs 프로젝트: tuita520/Davinet
        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;
            }
        }
예제 #7
0
 public Server(Settings settings, PeerDebug debug) : base(settings, debug)
 {
 }
예제 #8
0
 public Client(Settings settings, PeerDebug debug) : base(settings, debug)
 {
 }