forked from pusher/pusher-http-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New examples folder. Only has one at the moment: an async message send.
- Loading branch information
1 parent
aec6295
commit d24ee51
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'rubygems' | ||
require 'pusher' | ||
require 'eventmachine' | ||
require 'em-http-request' | ||
|
||
# To get these values: | ||
# - Go to https://app.pusherapp.com/ | ||
# - Click on Choose App. | ||
# - Click on one of your apps | ||
# - Click API Access | ||
Pusher.app_id = 'your_app_id' | ||
Pusher.key = 'your_key' | ||
Pusher.secret = 'your_secret' | ||
|
||
|
||
EM.run { | ||
deferrable = Pusher['test_channel'].trigger_async('my_event', 'hi') | ||
|
||
deferrable.callback { # called on success | ||
puts "Message sent successfully." | ||
EM.stop | ||
} | ||
deferrable.errback { |error| # called on error | ||
puts "Message could not be sent." | ||
puts error | ||
EM.stop | ||
} | ||
} |