Class: VlSync::Client
- Inherits:
-
Object
- Object
- VlSync::Client
- Defined in:
- lib/VlSync/client.rb
Instance Method Summary collapse
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #listener ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
4 5 6 7 8 9 10 |
# File 'lib/VlSync/client.rb', line 4 def initialize @args = ['--extraintf', 'rc', '--rc-host', "#{VlSync.opts[:hostname]}:#{VlSync.opts[:port]}"] puts "Client started at #{VlSync.opts[:hostname]} on port #{VlSync.opts[:port]}" @vlc = VlSync.vlc @pid = Process.spawn @vlc, *@args listener end |
Instance Method Details
#listener ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/VlSync/client.rb', line 12 def listener BasicSocket.do_not_reverse_lookup = true addr = [VlSync.opts[:bind], VlSync.opts[:port]+1] puts "Starting multicast at bind: #{addr[0]} on port #{addr[1]}" s = UDPSocket.new s.bind(addr[0], addr[1]) loop do , addr = s.recvfrom(255) if =~ /DISCOVER_VLSYNC/ sock = UDPSocket.new(addr[0]) puts "Host Found: #{addr[2]}" sock.send("PONG_VLSYNC", 0, addr[2], VlSync.opts[:port]) end end end |