Compare commits
No commits in common. "87d1ff8086dbf868797006a630a485fc52d7f022" and "259bed98232333302ce61723ad6045f6cceeb6a7" have entirely different histories.
87d1ff8086
...
259bed9823
@ -1,5 +1,5 @@
|
|||||||
name: telepathy
|
name: telepathy
|
||||||
version: 0.1.1
|
version: 0.1.0
|
||||||
|
|
||||||
authors:
|
authors:
|
||||||
- Danila Fedorin <danila.fedorin@gmail.com>
|
- Danila Fedorin <danila.fedorin@gmail.com>
|
||||||
|
@ -81,19 +81,30 @@ module Telepathy
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private def spawn_worker
|
private def spawn_workers
|
||||||
spawn do
|
spawn do
|
||||||
while @poll_running
|
loop do
|
||||||
begin
|
action = @poll_channel.receive
|
||||||
updates = get_updates 10
|
case action
|
||||||
process_updates updates
|
when Int64?
|
||||||
@last_update_id = updates.last?.try &.update_id.+(1) || @last_update_id
|
@last_update_id = action.nil? ? @last_update_id : action + 1
|
||||||
rescue
|
@update_channel.send get_updates 10
|
||||||
|
when Control
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
@poll_end_hooks.each do |hook|
|
spawn do
|
||||||
hook.call
|
loop do
|
||||||
|
item = @update_channel.receive
|
||||||
|
case item
|
||||||
|
when Array(Update)
|
||||||
|
process_updates(item)
|
||||||
|
@poll_channel.send item.last?.try &.update_id
|
||||||
|
when Control
|
||||||
|
@poll_channel.send item
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -101,15 +112,18 @@ module Telepathy
|
|||||||
def poll
|
def poll
|
||||||
if !@poll_running
|
if !@poll_running
|
||||||
@poll_running = true
|
@poll_running = true
|
||||||
@poll_start_hooks.each do |hook|
|
spawn_workers
|
||||||
hook.call
|
@poll_channel.send nil
|
||||||
end
|
@poll_start_hooks.each &.call
|
||||||
spawn_worker
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def end_poll
|
def end_poll
|
||||||
@poll_running = false
|
if @poll_running
|
||||||
|
@poll_running = false
|
||||||
|
@poll_channel.send Control::Done
|
||||||
|
@poll_end_hooks.each &.call
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
module Telepathy
|
module Telepathy
|
||||||
VERSION = "0.1.1"
|
VERSION = "0.1.0"
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user