eventflit-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c629865a4ea4d81e365d7637ab79526d6f8c78ed
4
+ data.tar.gz: 4a834cd1604769efecbfc728ebb5f2a7d932f494
5
+ SHA512:
6
+ metadata.gz: 2e0aa4cc3a4beb0e71315d000f4c52bd271a99aa0291ffd4695807da1eedc0b029db80097851382b2b45cc221d6fe2afead20f1819cb8486cf1a21fcf0c77cb3
7
+ data.tar.gz: 426e1e6d7f4f0f6a8755d78888245a8e6f793dc22c85dbc24cbe17570948aad3406c98d02c3597e499ed7d008365e1aef28bc9aa9eaab7f26e043f613b859ae7
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ *.log
2
+ .DS_Store
3
+ coverage
4
+ *.swp
5
+ *.swn
6
+ *.swm
7
+ *.swo
8
+ mkmf.log
9
+ test/rcov/*
10
+ .project
11
+ .bundle
12
+ pkg/*
13
+ run_example_playground
14
+ examples/hello_eventflit_playground.rb
15
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ bundler_args: --without debug
3
+ rvm:
4
+ - 1.8.7
5
+ - 1.9.2
6
+ - 1.9.3
7
+ - 2.0.0
8
+ - 2.1.0
9
+ - jruby-18mode
10
+ - jruby-19mode
data/CHANGELOG.md ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://www.rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Logan Koester
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # eventflit-client: Ruby WebSocket client for Eventflit Channels
2
+
3
+ `eventflit-client` is a Ruby gem for consuming WebSockets from Eventflit service.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ gem install eventflit-client
9
+ ```
10
+
11
+ This gem is compatible with jruby
12
+
13
+ ## Single-Threaded Usage
14
+
15
+ The application will pause at `eventflit.connect` and handle events from Eventflit Channels as they happen.
16
+
17
+ ```ruby
18
+ require 'eventflit-client'
19
+ cluster = 'cus1' # take this from your app's config in the dashboard
20
+ eventflit = EventflitClient::Socket.new(YOUR_APPLICATION_KEY, {
21
+ secure: true,
22
+ ws_host: "ws-#{cluster}.eventflit.com"
23
+ })
24
+
25
+ # Subscribe to two channels
26
+ eventflit.subscribe('channel1')
27
+ eventflit.subscribe('channel2')
28
+
29
+ # Subscribe to presence channel
30
+ eventflit.subscribe('presence-channel3', USER_ID)
31
+
32
+ # Subscribe to private channel
33
+ eventflit.subscribe('private-channel4', USER_ID)
34
+
35
+ # Subscribe to presence channel with custom data (user_id is mandatory)
36
+ eventflit.subscribe('presence-channel5', :user_id => USER_ID, :user_name => 'john')
37
+
38
+ # Bind to a global event (can occur on either channel1 or channel2)
39
+ eventflit.bind('globalevent') do |data|
40
+ puts data
41
+ end
42
+
43
+ # Bind to a channel event (can only occur on channel1)
44
+ eventflit['channel1'].bind('channelevent') do |data|
45
+ puts data
46
+ end
47
+
48
+ eventflit.connect
49
+ ```
50
+
51
+ ## Asynchronous Usage
52
+
53
+ With `eventflit.connect(true)`,
54
+ the connection to Eventflit Channels will be maintained in its own thread.
55
+ The connection will remain open in the background as long as your main application thread is running,
56
+ and you can continue to subscribe/unsubscribe to channels and bind new events.
57
+
58
+ ```ruby
59
+ require 'eventflit-client'
60
+ eventflit = EventflitClient::Socket.new(YOUR_APPLICATION_KEY)
61
+ eventflit.connect(true) # Connect asynchronously
62
+
63
+ # Subscribe to two channels
64
+ eventflit.subscribe('channel1')
65
+ eventflit.subscribe('channel2')
66
+
67
+ # Bind to a global event (can occur on either channel1 or channel2)
68
+ eventflit.bind('globalevent') do |data|
69
+ puts data
70
+ end
71
+
72
+ # Bind to a channel event (can only occur on channel1)
73
+ eventflit['channel1'].bind('channelevent') do |data|
74
+ puts data
75
+ end
76
+
77
+ loop do
78
+ sleep(1) # Keep your main thread running
79
+ end
80
+ ```
81
+
82
+ ## Using native WebSocket implementation
83
+
84
+ This gem depends on [the `websocket` gem](https://github.com/imanel/websocket-ruby)
85
+ which is a pure Ruby implementation of websockets.
86
+
87
+ However it can optionally use a native C or Java implementation for a 25% speed
88
+ increase by including [the `websocket-native` gem](https://github.com/imanel/websocket-ruby-native) in your Gemfile.
89
+
90
+ ## Copyright and license
91
+
92
+ See `LICENSE.txt`.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec