class TeletaskApi::Teletask
Public Class Methods
new(host, port = 55957)
click to toggle source
# File lib/teletask.rb, line 19 def initialize(host, port = 55957) @host = host @port = port #add_observer(self) end
Public Instance Methods
close()
click to toggle source
# File lib/teletask.rb, line 44 def close() puts "closing connection" @socket.close end
connect()
click to toggle source
# File lib/teletask.rb, line 29 def connect puts "Connecting to Teletask on #{@host} at port #{@port}..." @socket = TCPSocket.open @host, @port puts "Connected" @t = Thread.new{ while (data = @socket.recv(1024)) response = Response.parse data if response changed notify_observers(self, response) end end } end
finalize()
click to toggle source
# File lib/teletask.rb, line 25 def finalize close end
get(function, number)
click to toggle source
# File lib/teletask.rb, line 59 def get function, number f = Request.new Command::GET, function, number @socket.write f.to_s end
group_get()
click to toggle source
# File lib/teletask.rb, line 64 def group_get raise NotImplementedError.new end
keep_alive()
click to toggle source
# File lib/teletask.rb, line 49 def keep_alive f = Request.new Command::KEEPALIVE @socket.write f.to_s end
log(function, setting)
click to toggle source
# File lib/teletask.rb, line 68 def log function, setting r = Request.new Command::LOG, function, setting @socket.write r.to_s end
message()
click to toggle source
# File lib/teletask.rb, line 77 def message raise NotImplementedError.new end
report_event()
click to toggle source
# File lib/teletask.rb, line 73 def report_event raise NotImplementedError.new end
set(function, number, setting)
click to toggle source
# File lib/teletask.rb, line 54 def set function, number, setting f = Request.new Command::SET, function, number, setting @socket.write f.to_s end