示例#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
        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
        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)
 {
 }