Class: Skype::OS::WindowsEventQueue
- Inherits:
-
Object
- Object
- Skype::OS::WindowsEventQueue
- Defined in:
- lib/skype/os/window_event_queue.rb
Instance Attribute Summary collapse
-
#notify_selector ⇒ Object
readonly
Returns the value of attribute notify_selector.
- #received_count ⇒ Object readonly
Instance Method Summary collapse
- #_pause ⇒ Object
- #add_hook(sym, block = Proc.new) ⇒ Object
- #callback ⇒ Object
- #close ⇒ Object
- #del_hook(sym, block = nil) ⇒ Object
- #exist_hook?(sym) ⇒ Boolean
- #get_hook(sym) ⇒ Object
-
#initialize(windows) ⇒ WindowsEventQueue
constructor
A new instance of WindowsEventQueue.
- #length ⇒ Object
- #messageloop ⇒ Object
- #messagepolling ⇒ Object
- #pause(&block) ⇒ Object
- #paused? ⇒ Boolean
- #play ⇒ Object
- #push(response) ⇒ Object
- #push_block(block = Proc.new) ⇒ Object
- #push_detached_hook ⇒ Object
- #push_hook(sym, *args) ⇒ Object
- #set_notify_selector(block = Proc.new) ⇒ Object
- #start_messageloop ⇒ Object
Constructor Details
#initialize(windows) ⇒ WindowsEventQueue
Returns a new instance of WindowsEventQueue.
12 13 14 15 16 |
# File 'lib/skype/os/window_event_queue.rb', line 12 def initialize windows @windows = windows @pause_count = 0 @pause_mutex = Mutex.new end |
Instance Attribute Details
#notify_selector ⇒ Object (readonly)
Returns the value of attribute notify_selector.
42 43 44 |
# File 'lib/skype/os/window_event_queue.rb', line 42 def notify_selector @notify_selector end |
#received_count ⇒ Object
28 29 30 |
# File 'lib/skype/os/window_event_queue.rb', line 28 def received_count @received_count ||= 0 end |
Instance Method Details
#_pause ⇒ Object
141 142 143 |
# File 'lib/skype/os/window_event_queue.rb', line 141 def _pause @pause_mutex.synchronized{@pause_count += 1} end |
#add_hook(sym, block = Proc.new) ⇒ Object
52 53 54 |
# File 'lib/skype/os/window_event_queue.rb', line 52 def add_hook sym, block=Proc.new hook[sym].push block end |
#callback ⇒ Object
34 35 36 |
# File 'lib/skype/os/window_event_queue.rb', line 34 def callback @callback ||= Hash.new end |
#close ⇒ Object
122 123 124 125 |
# File 'lib/skype/os/window_event_queue.rb', line 122 def close queue.clear queue.push :exit end |
#del_hook(sym, block = nil) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/skype/os/window_event_queue.rb', line 56 def del_hook sym, block=nil unless block hook[sym] = Array.new else hook[sym].delete block end end |
#exist_hook?(sym) ⇒ Boolean
64 65 66 67 68 69 70 |
# File 'lib/skype/os/window_event_queue.rb', line 64 def exist_hook? sym if hook[sym].length > 0 return true else return false end end |
#get_hook(sym) ⇒ Object
72 73 74 |
# File 'lib/skype/os/window_event_queue.rb', line 72 def get_hook sym hook[sym] ? true : false end |
#length ⇒ Object
24 25 26 |
# File 'lib/skype/os/window_event_queue.rb', line 24 def length @queue.length end |
#messageloop ⇒ Object
103 104 105 106 107 |
# File 'lib/skype/os/window_event_queue.rb', line 103 def while callback = queue.shift break unless callback end end |
#messagepolling ⇒ Object
109 110 111 112 |
# File 'lib/skype/os/window_event_queue.rb', line 109 def return (queue.shift) unless queue.empty? return true end |
#pause(&block) ⇒ Object
131 132 133 134 135 136 137 138 139 |
# File 'lib/skype/os/window_event_queue.rb', line 131 def pause &block if block _pause block.call play else _pause end end |
#paused? ⇒ Boolean
127 128 129 |
# File 'lib/skype/os/window_event_queue.rb', line 127 def paused? @pause_count > 0 end |
#play ⇒ Object
145 146 147 |
# File 'lib/skype/os/window_event_queue.rb', line 145 def play @pause_mutex.synchronized{@pause_count -=1} end |
#push(response) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/skype/os/window_event_queue.rb', line 76 def push response self.received_count += 1 response = response.chop push_received_hook(response) cmd_num, res = response_match(response) if cmd_num @windows.wmHandler.del_send_buffer cmd_num.to_i set_cmd_response(cmd_num, res) else when_detached if response_detached?(res) push_notify res end end |
#push_block(block = Proc.new) ⇒ Object
95 96 97 |
# File 'lib/skype/os/window_event_queue.rb', line 95 def push_block block=Proc.new queue.push block end |
#push_detached_hook ⇒ Object
149 150 151 152 153 |
# File 'lib/skype/os/window_event_queue.rb', line 149 def push_detached_hook #windows.attached = false queue.push_block{ call_hook(:detached) } #Skype.attach end |
#push_hook(sym, *args) ⇒ Object
91 92 93 |
# File 'lib/skype/os/window_event_queue.rb', line 91 def push_hook sym, *args queue.push_block{ call_hook(sym, *args) } end |
#set_notify_selector(block = Proc.new) ⇒ Object
38 39 40 |
# File 'lib/skype/os/window_event_queue.rb', line 38 def set_notify_selector block=Proc.new @notify_selector = block end |
#start_messageloop ⇒ Object
99 100 101 |
# File 'lib/skype/os/window_event_queue.rb', line 99 def Thread.new{} end |