Exemplo n.º 1
0
        public void Broadcast(byte channelID, ref Packet packet, Peer[] peers)
        {
            if (peers == null)
            {
                throw new ArgumentNullException("peers");
            }

            ThrowIfNotCreated();

            packet.ThrowIfNotCreated();

            if (peers.Length > 0)
            {
                IntPtr[] nativePeers = ArrayPool.GetPointerBuffer();
                int      nativeCount = 0;

                for (int i = 0; i < peers.Length; i++)
                {
                    if (peers[i].NativeData != IntPtr.Zero)
                    {
                        nativePeers[nativeCount] = peers[i].NativeData;
                        nativeCount++;
                    }
                }

                Native.enet_host_broadcast_selective(nativeHost, channelID, packet.NativeData, nativePeers, (IntPtr)nativeCount);
            }

            packet.NativeData = IntPtr.Zero;
        }
Exemplo n.º 2
0
        public void Broadcast(byte channelID, ref Packet packet, ref Peer[] peers)
        {
            CheckCreated();

            packet.CheckCreated();

            if (peers.Length > 0)
            {
                IntPtr[] nativePeers = ArrayPool.GetPointerBuffer();
                int      nativeCount = 0;

                for (int i = 0; i < peers.Length; i++)
                {
                    if (peers[i].NativeData != IntPtr.Zero)
                    {
                        nativePeers[nativeCount] = peers[i].NativeData;
                        nativeCount++;
                    }
                }

                Native.enet_host_broadcast_selective(nativeHost, channelID, packet.NativeData, nativePeers, (IntPtr)nativeCount);
            }

            packet.NativeData = IntPtr.Zero;
        }