class RNotify::Server
Public Class Methods
new(password)
click to toggle source
# File lib/r_notify/server.rb, line 4 def initialize(password) @notification_queue = Queue.new @password = password Thread.new do loop do push(:heartbeat) sleep 30 end end end
Public Instance Methods
listen(password)
click to toggle source
# File lib/r_notify/server.rb, line 15 def listen(password) authenticate password @notification_queue.pop end
push(password, notification)
click to toggle source
# File lib/r_notify/server.rb, line 20 def push(password, notification) authenticate password @notification_queue.push(notification) end
Private Instance Methods
authenticate(password)
click to toggle source
# File lib/r_notify/server.rb, line 29 def authenticate(password) sleep 1 # slow down brute forcing raise AuthError unless password == @password end