Esempio n. 1
0
        public Peer(Settings settings, PeerDebug debug) : this(settings)
        {
            this.debug = debug;

            if (debug != null)
            {
                netManager.SimulatePacketLoss         = debug.settings.simulatePacketLoss;
                netManager.SimulationPacketLossChance = debug.settings.packetLossChance;
            }
        }
Esempio n. 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;
        }
Esempio n. 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);
        }
Esempio n. 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();
        }
Esempio n. 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>();
        }
Esempio n. 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;
            }
        }
Esempio n. 7
0
 public Server(Settings settings, PeerDebug debug) : base(settings, debug)
 {
 }
Esempio n. 8
0
 public Client(Settings settings, PeerDebug debug) : base(settings, debug)
 {
 }