Exemple #1
0
    async Task SendUDPPacket(List <byte> data)
    {
        UDPListener    listener    = UDPListener.Instance;
        UDPBroadcaster broadcaster = UDPBroadcaster.Instance;

        if (listener != null)
        {
            await listener.SendUDPMessage(udpEndpoint, data.ToArray());
        }
        else if (broadcaster != null)
        {
            await broadcaster.SendUDPMessage(udpEndpoint, data.ToArray());
        }
        else
        {
            throw new Exception("No available UDP channel to send the message through!");
        }
    }