aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable
diff options
context:
space:
mode:
Diffstat (limited to 'actioncable')
-rw-r--r--actioncable/README.md24
-rw-r--r--actioncable/actioncable.gemspec2
-rw-r--r--actioncable/lib/action_cable/server/base.rb2
-rw-r--r--actioncable/lib/action_cable/server/broadcasting.rb2
-rw-r--r--actioncable/test/channel/base_test.rb4
5 files changed, 16 insertions, 18 deletions
diff --git a/actioncable/README.md b/actioncable/README.md
index 13b79d15ca..823964343a 100644
--- a/actioncable/README.md
+++ b/actioncable/README.md
@@ -16,7 +16,8 @@ WebSockets open to your application if they use multiple browser tabs or devices
The client of a WebSocket connection is called the consumer.
Each consumer can in turn subscribe to multiple cable channels. Each channel encapsulates
-a logical unit of work, similar to what a controller does in a regular MVC setup. For example, you could have a `ChatChannel` and a `AppearancesChannel`, and a consumer could be subscribed to either
+a logical unit of work, similar to what a controller does in a regular MVC setup. For example,
+you could have a `ChatChannel` and a `AppearancesChannel`, and a consumer could be subscribed to either
or to both of these channels. At the very least, a consumer should be subscribed to one channel.
When the consumer is subscribed to a channel, they act as a subscriber. The connection between
@@ -86,8 +87,8 @@ potentially disconnect them all if the user is deleted or deauthorized).
The client-side needs to setup a consumer instance of this connection. That's done like so:
```coffeescript
-# app/assets/javascripts/application_cable.coffee
-#= require cable
+# app/assets/javascripts/cable.coffee
+#= require action_cable
@App = {}
App.cable = Cable.createConsumer("ws://cable.example.com")
@@ -202,7 +203,7 @@ end
```
```coffeescript
-# Client-side which assumes you've already requested the right to send web notifications
+# Client-side, which assumes you've already requested the right to send web notifications
App.cable.subscriptions.create "WebNotificationsChannel",
received: (data) ->
new Notification data["title"], body: data["body"]
@@ -236,7 +237,7 @@ end
Pass an object as the first argument to `subscriptions.create`, and that object will become your params hash in your cable channel. The keyword `channel` is required.
```coffeescript
-# Client-side which assumes you've already requested the right to send web notifications
+# Client-side, which assumes you've already requested the right to send web notifications
App.cable.subscriptions.create { channel: "ChatChannel", room: "Best Room" },
received: (data) ->
@appendLine(data)
@@ -279,7 +280,7 @@ end
```
```coffeescript
-# Client-side which assumes you've already requested the right to send web notifications
+# Client-side, which assumes you've already requested the right to send web notifications
App.chatChannel = App.cable.subscriptions.create { channel: "ChatChannel", room: "Best Room" },
received: (data) ->
# data => { sent_by: "Paul", body: "This is a cool chat app." }
@@ -305,16 +306,9 @@ By default, `ActionCable::Server::Base` will look for a configuration file in `R
```yaml
production: &production
- :url: redis://10.10.3.153:6381
- :host: 10.10.3.153
- :port: 6381
- :timeout: 1
+ url: redis://10.10.3.153:6381
development: &development
- :url: redis://localhost:6379
- :host: localhost
- :port: 6379
- :timeout: 1
- :inline: true
+ url: redis://localhost:6379
test: *development
```
diff --git a/actioncable/actioncable.gemspec b/actioncable/actioncable.gemspec
index ca2f987934..74c21bd24d 100644
--- a/actioncable/actioncable.gemspec
+++ b/actioncable/actioncable.gemspec
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.license = 'MIT'
s.author = ['Pratik Naik', 'David Heinemeier Hansson']
- s.email = ['pratiknaik@gmail.com', 'david@heinemeierhansson.com']
+ s.email = ['pratiknaik@gmail.com', 'david@loudthinking.com']
s.homepage = 'http://rubyonrails.org'
s.files = Dir['CHANGELOG.md', 'MIT-LICENSE', 'README.md', 'lib/**/*']
diff --git a/actioncable/lib/action_cable/server/base.rb b/actioncable/lib/action_cable/server/base.rb
index 5f44bdd1c3..740e4b301e 100644
--- a/actioncable/lib/action_cable/server/base.rb
+++ b/actioncable/lib/action_cable/server/base.rb
@@ -42,7 +42,7 @@ module ActionCable
@worker_pool ||= ActionCable::Server::Worker.pool(size: config.worker_pool_size)
end
- # Requires and returns an hash of all the channel class constants keyed by name.
+ # Requires and returns a hash of all the channel class constants keyed by name.
def channel_classes
@channel_classes ||= begin
config.channel_paths.each { |channel_path| require channel_path }
diff --git a/actioncable/lib/action_cable/server/broadcasting.rb b/actioncable/lib/action_cable/server/broadcasting.rb
index 6e0fbae387..c759239a0e 100644
--- a/actioncable/lib/action_cable/server/broadcasting.rb
+++ b/actioncable/lib/action_cable/server/broadcasting.rb
@@ -15,7 +15,7 @@ module ActionCable
# ActionCable.server.broadcast \
# "web_notifications_1", { title: 'New things!', body: 'All shit fit for print' }
#
- # # Client-side coffescript which assumes you've already requested the right to send web notifications
+ # # Client-side coffescript, which assumes you've already requested the right to send web notifications
# App.cable.subscriptions.create "WebNotificationsChannel",
# received: (data) ->
# new Notification data['title'], body: data['body']
diff --git a/actioncable/test/channel/base_test.rb b/actioncable/test/channel/base_test.rb
index 580338b44a..506d41d9a2 100644
--- a/actioncable/test/channel/base_test.rb
+++ b/actioncable/test/channel/base_test.rb
@@ -145,4 +145,8 @@ class ActionCable::Channel::BaseTest < ActiveSupport::TestCase
assert_equal expected, @connection.last_transmission
end
+ test "actions available on Channel" do
+ available_actions = ["room", "last_action", "subscribed", "unsubscribed", "toggle_subscribed", "leave", "speak", "subscribed?", "get_latest", "chatters", "topic"].to_set
+ assert_equal available_actions, ChatChannel.action_methods
+ end
end