示例#1
0
        public ListenerSession(int port, NetworkPool pool)
        {
            endpoint = new IPEndPoint(IPAddress.Loopback, port);

            client = pool.New();
            client.Bind();
        }
示例#2
0
        public void Execute(PeerConnectorContext context)
        {
            NetworkPool       pool       = context.Dependencies.Network;
            NetworkConnection connection = pool.Create(socket, NetworkDirection.Outgoing, endpoint);

            context.Hooks.CallConnectionEstablished(connection);
        }
示例#3
0
    public static void SaveJSON(NetworkPool pool)
    {
        string SavePath = System.IO.Directory.GetCurrentDirectory().ToString() + "//" + "NetworkPool//White//";
        string output   = JsonConvert.SerializeObject(pool);

        File.WriteAllText(SavePath + ".json", output);
        Console.ForegroundColor = ConsoleColor.DarkGreen;
    }
        public HandshakeNegotiatorPassive(NetworkPool pool, NetworkConnection connection, HandshakeNegotiatorPassiveContext context, HandshakeNegotiatorHooks hooks)
        {
            this.context = context;
            this.hooks   = hooks;

            this.connection  = new HandshakeConnection(pool, connection, hooks);
            this.credentials = HandshakeCryptography.Generate();
            this.keys        = new HandshakeKeyContainer();
        }
示例#5
0
        public ConnectorSession(NetworkPool pool, PeerConnector connector)
        {
            int?port;

            this.connector = connector;
            this.server    = pool.New();

            server.Bind(out port);
            server.Listen(1);

            endpoint = new IPEndPoint(IPAddress.Loopback, port.Value);
        }
示例#6
0
        /// <summary>
        /// Creates a networked object pool. Can only be called from the server
        /// </summary>
        /// <param name="poolName">Name of the pool</param>
        /// <param name="spawnablePrefabIndex">The index of the prefab to use in the spawnablePrefabs array</param>
        /// <param name="size">The amount of objects in the pool</param>
        public static void CreatePool(string poolName, int spawnablePrefabIndex, uint size = 16)
        {
            if (!NetworkingManager.singleton.isServer)
            {
                Debug.LogWarning("MLAPI: Pools can only be created on the server");
                return;
            }
            NetworkPool pool = new NetworkPool(spawnablePrefabIndex, size, PoolIndex);

            PoolNamesToIndexes.Add(poolName, PoolIndex);
            PoolIndex++;
        }
示例#7
0
        /// <summary>
        /// Creates a networked object pool. Can only be called from the server
        /// </summary>
        /// <param name="poolName">Name of the pool</param>
        /// <param name="spawnablePrefabIndex">The index of the prefab to use in the spawnablePrefabs array</param>
        /// <param name="size">The amount of objects in the pool</param>
        public static void CreatePool(string poolName, int spawnablePrefabIndex, uint size = 16)
        {
            if (!NetworkingManager.singleton.isServer)
            {
                if (LogHelper.CurrentLogLevel <= LogLevel.Normal)
                {
                    LogHelper.LogWarning("Pools can only be created on the server");
                }
                return;
            }
            NetworkPool pool = new NetworkPool(spawnablePrefabIndex, size, PoolIndex);

            PoolNamesToIndexes.Add(poolName, PoolIndex);
            PoolIndex++;
        }
示例#8
0
    public void RpcCreateCard()
    {
        // Spawn player card object
        _PlayerCardGO = NetworkPool.ServerSpawn(MenuCardPrefab, Vector3.zero, Quaternion.identity);
        _PlayerCardGO.transform.SetParent(NetworkingMenuManager.Instance.FolderPlayerCards);

        // Set position in 2D space
        RectTransform rect = _PlayerCardGO.GetComponent <RectTransform>();

        rect.localPosition    = new Vector2(0f, 0f);
        rect.anchoredPosition = new Vector2(0, -40 - (NetworkingMenuManager.Instance.numPlayers - 1) * 80);
        rect.sizeDelta        = new Vector2(0, 80);

        //rect.rect.Set(0f, 0f, rect.rect.width, rect.rect.height);
        //rect.rect.position.Set(rect.rect.position.x, -40 - (NetworkingMenuManager.Instance.numPlayers - 1) * 80);
    }
示例#9
0
        public ConnectorFixture()
        {
            pipeline = new LeakPipeline();
            pipeline.Start();

            worker = new CompletionThread();
            worker.Start();

            pool =
                new NetworkPoolBuilder()
                .WithPipeline(pipeline)
                .WithWorker(worker)
                .WithMemory(new ConnectorMemory())
                .Build();

            pool.Start();

            hooks = new PeerConnectorHooks();
        }
示例#10
0
        public LoopFixture()
        {
            pipeline = new LeakPipeline();
            pipeline.Start();

            worker = new CompletionThread();
            worker.Start();

            pool =
                new NetworkPoolBuilder()
                .WithPipeline(pipeline)
                .WithWorker(worker)
                .WithMemory(new LoopMemory())
                .Build();

            pool.Start();

            hooks   = new ReceiverHooks();
            samples = new LoopSamples();
        }
示例#11
0
        public NegotiatorFixture()
        {
            pipeline = new LeakPipeline();
            pipeline.Start();

            worker = new CompletionThread();
            worker.Start();

            pool =
                new NetworkPoolBuilder()
                .WithPipeline(pipeline)
                .WithWorker(worker)
                .WithMemory(new NegotiatorMemory())
                .Build();

            pool.Start();

            hooks      = new HandshakeNegotiatorHooks();
            negotiator =
                new HandshakeNegotiatorBuilder()
                .WithNetwork(pool)
                .Build(hooks);
        }
示例#12
0
 public HandshakeNegotiatorBuilder WithNetwork(NetworkPool network)
 {
     dependencies.Network = network;
     return(this);
 }
示例#13
0
 public PeerListenerBuilder WithNetwork(NetworkPool network)
 {
     dependencies.Network = network;
     return(this);
 }
示例#14
0
 public HandshakeConnection(NetworkPool pool, NetworkConnection connection, HandshakeNegotiatorHooks hooks)
 {
     this.pool       = pool;
     this.connection = connection;
     this.hooks      = hooks;
 }
示例#15
0
 public PeerConnectorBuilder WithNetwork(NetworkPool network)
 {
     dependencies.Network = network;
     return(this);
 }