Sha256: 8efa33ca7c34f6bfadd59b6c77d8c5583f43d2c0c32a3be1150d2584dfe44593
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
require 'rack' require 'socket' module AirPlayer class Server attr_reader :uri def initialize(video_path) @server = Rack::Server.new( :server => :webrick, :Host => local_ip, :Port => 7070, :app => Rack::File.new(video_path) ) @uri = "http://#{@server.options[:Host]}:#{@server.options[:Port]}" end def start Thread.start do # Output WEBrick access log to file $stderr = File.open(Logger.path, File::WRONLY | File::APPEND | File::CREAT) @server.start $stderr = STDERR end end def stop @server.server.shutdown end private # networking - Getting the Hostname or IP in Ruby on Rails - Stack Overflow # http://stackoverflow.com/questions/42566/getting-the-hostname-or-ip-in-ruby-on-rails def local_ip # turn off reverse DNS resolution temporarily orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true UDPSocket.open do |s| s.connect('8.8.8.8', 1) s.addr.last end ensure Socket.do_not_reverse_lookup = orig end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
airplayer-0.0.6 | lib/airplayer/server.rb |