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

            IsCreated();

            packet.IsCreated();

            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;
        }
Beispiel #2
0
        public bool Send(byte channelID, ref Packet packet)
        {
            IsCreated();

            packet.IsCreated();

            return(Native.enet_peer_send(nativePeer, channelID, packet.NativeData) == 0);
        }
Beispiel #3
0
        public void Broadcast(byte channelID, ref Packet packet)
        {
            IsCreated();

            packet.IsCreated();
            Native.enet_host_broadcast(nativeHost, channelID, packet.NativeData);
            packet.NativeData = IntPtr.Zero;
        }
Beispiel #4
0
        public void Broadcast(byte channelID, ref Packet packet, Peer excludedPeer)
        {
            IsCreated();

            packet.IsCreated();
            Native.enet_host_broadcast_exclude(nativeHost, channelID, packet.NativeData, excludedPeer.NativeData);
            packet.NativeData = IntPtr.Zero;
        }
Beispiel #5
0
        // == ADDITIONS NOT AVAILABLE IN UPSTREAM REPOSITORY == //
        // These are placed here to ensure that merge conflicts aren't a
        // pain in the ass.

        // SendAndReturnStatusCode returns either 0 if the send was successful,
        // or the ENET return code if not. Sometimes a bool is not enough to determine
        // the root cause of a issue.
        public int SendAndReturnStatusCode(byte channelID, ref Packet packet)
        {
            IsCreated();

            packet.IsCreated();

            return(Native.enet_peer_send(nativePeer, channelID, packet.NativeData));
        }