Sha256: d9ad8d00de69780904d6a448ba50fcf39f6d38520a9e489fc4aad805db1d2942
Contents?: true
Size: 757 Bytes
Versions: 1
Compression:
Stored size: 757 Bytes
Contents
require 'rest_client' class Pusher class << self attr_accessor :host, :port attr_writer :key, :secret end self.host = 'api.pusherapp.com' self.port = 80 def self.[](channel_id) @channels ||= {} @channels[channel_id.to_sym] ||= Channel.new(@key, channel_id) end class Channel def initialize(key, id) @http = RestClient::Resource.new( "http://#{Pusher.host}:#{Pusher.port}/app/#{key}/channel/#{id}" ) end def trigger(event_name, data) begin @http.post( :event => event_name, :data => data ) rescue StandardError => e handle_error e end end private def handle_error(e) puts e.inspect end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pusher-0.2.0 | lib/pusher.rb |