Class: MMPlayer::Player::Messenger
- Inherits:
-
Object
- Object
- MMPlayer::Player::Messenger
- Defined in:
- lib/mmplayer/player/messenger.rb
Overview
Handle sending MPlayer messages
Constant Summary collapse
- FREQUENCY_LIMIT =
Throttle messages to 1 per this number seconds
0.1
Instance Method Summary collapse
-
#initialize ⇒ Messenger
constructor
A new instance of Messenger.
-
#send_message(&block) ⇒ Hash?
Send mplayer a message asynch.
Constructor Details
#initialize ⇒ Messenger
Returns a new instance of Messenger.
10 11 12 |
# File 'lib/mmplayer/player/messenger.rb', line 10 def initialize = [] end |
Instance Method Details
#send_message(&block) ⇒ Hash?
Send mplayer a message asynch
16 17 18 19 20 21 22 23 |
# File 'lib/mmplayer/player/messenger.rb', line 16 def (&block) = Time.now.to_f # Throttled messages are disregarded if .empty? || !throttle?(, .last[:timestamp]) thread = ::MMPlayer::Thread.new(&block) (thread, ) end end |