コード例 #1
0
ファイル: ENetHost.cs プロジェクト: darkisgay/ENet.Managed
        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));
        }