Class: RNotify::Server
- Inherits:
-
Object
- Object
- RNotify::Server
- Defined in:
- lib/r_notify/server.rb
Defined Under Namespace
Classes: AuthError
Instance Method Summary collapse
-
#initialize(password) ⇒ Server
constructor
A new instance of Server.
- #listen(password) ⇒ Object
- #push(password, notification) ⇒ Object
Constructor Details
#initialize(password) ⇒ Server
Returns a new instance of Server.
4 5 6 7 8 9 10 11 12 13 |
# 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 |
Instance Method Details
#listen(password) ⇒ Object
15 16 17 18 |
# File 'lib/r_notify/server.rb', line 15 def listen(password) authenticate password @notification_queue.pop end |
#push(password, notification) ⇒ Object
20 21 22 23 |
# File 'lib/r_notify/server.rb', line 20 def push(password, notification) authenticate password @notification_queue.push(notification) end |