lib/dazeus/dazeus.rb in dazeus-0.0.1.201306161619 vs lib/dazeus/dazeus.rb in dazeus-0.0.1.201306161750
- old
+ new
@@ -66,11 +66,11 @@
end
def names(network, channel, &block)
fn = lambda do |response|
block.call(response)
- unsubscribe &fn
+ unsubscribe('NAMES', &fn)
end
subscribe('NAMES', &fn)
send_names(network, channel)
end
@@ -80,11 +80,11 @@
end
def whois(network, nick, &block)
fn = lambda do |response|
block.call(response)
- unsubscribe &fn
+ unsubscribe('WHOIS', &fn)
end
subscribe('WHOIS', &fn)
send_whois(network, nick)
end
@@ -192,22 +192,31 @@
@subscribers['COMMAND'][command].push [network, callback]
success
end
def run
+
loop do
+ break if conn.closed?
handle_event conn.receive
end
end
+ def stop
+ conn.close
+ end
+
private
def send_receive(message)
conn.send message
response = nil
loop do
+ break if conn.closed?
response = conn.receive
break unless handle_event response
end
+
+ return {} if response == nil
response
end
def handle_event(response)
if response.has_key?('event')