class Libuv::Loop

Public Instance Methods

observer() click to toggle source
# File lib/orchestrator/status.rb, line 259
def observer
    @observer ||= ::Orchestrator::Status.new(@loop)
    @observer
end
udp_broadcast(data, port = 9, ip = '<broadcast>') click to toggle source
# File lib/orchestrator/datagram_server.rb, line 85
def udp_broadcast(data, port = 9, ip = '<broadcast>')
    if @udp_broadcast
        @udp_broadcast.send(ip, port, data)
    else
        CRITICAL.synchronize {
            return @udp_broadcast.send(ip, port, data) if @udp_broadcast
            
            port = Rails.configuration.orchestrator.broadcast_port || 0

            if port == 0
                @udp_broadcast = ::UV.open_datagram_socket(::Orchestrator::UdpBroadcast)
            elsif defined? @@udp_broadcast
                @udp_broadcast = @@udp_broadcast
            else # define a class variable at the specified port
                @udp_broadcast = ::UV.open_datagram_socket(::Orchestrator::UdpBroadcast, '0.0.0.0', port)
                @@udp_broadcast = @udp_broadcast
            end

            @udp_broadcast.send(ip, port, data)
        }
    end
end
udp_service() click to toggle source
# File lib/orchestrator/datagram_server.rb, line 64
def udp_service
    if @udp_service
        @udp_service
    else
        CRITICAL.synchronize {
            return @udp_service if @udp_service

            port = Rails.configuration.orchestrator.datagram_port || 0

            if port == 0
                @udp_service = ::UV.open_datagram_socket(::Orchestrator::UdpService)
            elsif defined? @@udp_service
                @udp_service = @@udp_service
            else # define a class variable at the specified port
                @udp_service = ::UV.open_datagram_socket(::Orchestrator::UdpService, '0.0.0.0', port)
                @@udp_service = @udp_service
            end
        }
    end
end
wake_device(mac, ip = '<broadcast>') click to toggle source
# File lib/orchestrator/datagram_server.rb, line 108
def wake_device(mac, ip = '<broadcast>')
    mac = mac.gsub(/(0x|[^0-9A-Fa-f])*/, "").scan(/.{2}/).pack("H*H*H*H*H*H*")
    magicpacket = (0xff.chr) * 6 + mac * 16
    udp_broadcast(magicpacket, 9, ip)
end