Sha256: 22286706f7096731a810199e1aa685dead7fa01df57a1b35ca9ba53e1c1815d0
Contents?: true
Size: 742 Bytes
Versions: 4
Compression:
Stored size: 742 Bytes
Contents
require 'thread' module Rype class Events class << self def on(event) case event when :chatmessage_received Rype::Api.instance.on_notification("CHATMESSAGE (.*) STATUS RECEIVED") do |chatmessage_id| yield Chatmessage.new(chatmessage_id) end when :chats_received Rype::Api.instance.on_notification("CHATS (.*)") do |chatlist| yield chatlist.split(', ').map { |chatname| Chat.new(chatname) } end end end def initialize_listeners mutex = Mutex.new Rype::Events.on(:chats_received) do |chats| mutex.synchronize { Rype::Chat.chats = chats } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rype-0.0.4 | lib/rype/events.rb |
rype-0.0.3 | lib/rype/events.rb |
rype-0.0.2 | lib/rype/events.rb |
rype-0.0.1 | lib/rype/events.rb |