jugglite 0.6.0 → 1.0.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +13 -1
- data/lib/jugglite/app.rb +5 -0
- data/lib/jugglite/sse_connection.rb +3 -0
- data/lib/jugglite/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 697ae333596582eea2d8786ca65f1a38c04fd351
|
4
|
+
data.tar.gz: a6b798faf7f89cb54a7407607c55dc5a6eedf975
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43e9167fef4b48692684495c24dcf30f679c2fb95bdb9392ee91fa66765d680a9d01fa715d1efb28bf807d0cdf2536e217ab7b14c0feb56c2155a6d15a9ca438
|
7
|
+
data.tar.gz: dd19ee67bd88235ab5d1e5107f8eea18e71ab8c92f378350c9f2e811501d39ee7f1500f51153c463a4135a88b187badfd35bd0306a159bf6a4286b44c9859d07
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -36,7 +36,19 @@ This setup is great because it allows you to do channel authorization on a per r
|
|
36
36
|
user_id = request.session['user_id']
|
37
37
|
user_id ? ['broadcast', "player_#{user_id}"] : []
|
38
38
|
}
|
39
|
-
|
39
|
+
|
40
|
+
@on_register = ->(connection) {
|
41
|
+
# Store something in connection.data
|
42
|
+
# connection.request holds the Rack::Request
|
43
|
+
}
|
44
|
+
|
45
|
+
@on_unregister = ->(connection) {
|
46
|
+
# Called when the connection is dropped or closed.
|
47
|
+
# You can access the connection.data set in the +on_register+ call
|
48
|
+
# Or use the connect.request.
|
49
|
+
}
|
50
|
+
|
51
|
+
get 'stream', to: Jugglite::App.new(nil, namespace: "app:#{Rails.env}:", allowed_channels: @allowed_channels, on_register: @on_register, on_unregister: @on_unregister)
|
40
52
|
|
41
53
|
# ...
|
42
54
|
```
|
data/lib/jugglite/app.rb
CHANGED
@@ -17,6 +17,9 @@ module Jugglite
|
|
17
17
|
# +allowed_channels+ :
|
18
18
|
# * an array with allowed channel names
|
19
19
|
# * a proc that takes a Rack::Request and returns an array of allowed channels for that particular request
|
20
|
+
# +on_register+ : a Proc that takes a Sse::Connection as argument and is called right after a connection is initiated.
|
21
|
+
# +on_unregister+ : a Proc that takes a Sse::Connection as argument and is called right after a connection is initiated.
|
22
|
+
# The same Sse::Connection object will be passed to the on_register and on_unregister callbacks. You can for example use the +connection.data+ attribute to store an identifier.
|
20
23
|
def initialize(app = nil, options = {})
|
21
24
|
@app = app
|
22
25
|
@options = {
|
@@ -100,10 +103,12 @@ module Jugglite
|
|
100
103
|
def register_connection(connection)
|
101
104
|
requested_channels = channels_for_request(connection.request)
|
102
105
|
subscribe_to_new_channels(requested_channels - @redis_channels)
|
106
|
+
@options[:on_register].call(connection) if @options[:on_register]
|
103
107
|
@subscription_map[connection] = requested_channels
|
104
108
|
end
|
105
109
|
|
106
110
|
def unregister_connection(connection)
|
111
|
+
@options[:on_unregister].call(connection) if @options[:on_register]
|
107
112
|
@subscription_map.delete(connection)
|
108
113
|
end
|
109
114
|
|
data/lib/jugglite/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jugglite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- andruby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thin
|
@@ -107,9 +107,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- - "
|
110
|
+
- - ">"
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version:
|
112
|
+
version: 1.3.1
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
115
|
rubygems_version: 2.4.5
|