Exemple #1
0
        public ENetPeer Connect(IPEndPoint endPoint, byte channels, uint data)
        {
            CheckDispose();

            if (channels < 1)
            {
                throw new ArgumentOutOfRangeException("channels");
            }

            Native.ENetAddress address = Native.ENetAddress.FromEndPoint(endPoint);
            var native = LibENet.HostConnect(Pointer, &address, (UIntPtr)channels, data);

            if (((IntPtr)native) == IntPtr.Zero)
            {
                throw new Exception("Failed to initiate connection.");
            }

            return(new ENetPeer(this, native));
        }