firehose 1.3.6 → 2.1.0
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 +5 -5
- data/CHANGELOG.md +31 -10
- data/{LICENSE.txt → LICENSE} +6 -6
- data/README.md +379 -187
- data/app/assets/javascripts/firehose.js +258 -0
- data/config/importmap.rb +1 -0
- data/db/migrate/20260214185244_create_firehose_events.rb +23 -0
- data/lib/commands/firehose_command.rb +119 -0
- data/lib/firehose/channel.rb +40 -0
- data/lib/firehose/cleanup_job.rb +21 -0
- data/lib/firehose/engine.rb +36 -0
- data/lib/firehose/helper.rb +40 -0
- data/lib/firehose/models/channel.rb +12 -0
- data/lib/firehose/models/message.rb +11 -0
- data/lib/firehose/queue.rb +44 -0
- data/lib/firehose/server.rb +930 -17
- data/lib/firehose/sse.rb +187 -0
- data/lib/firehose/stream.rb +32 -0
- data/lib/firehose/streamable.rb +25 -0
- data/lib/firehose/websocket.rb +242 -0
- data/lib/firehose.rb +67 -15
- data/lib/generators/firehose/install/install_generator.rb +43 -0
- data/lib/generators/firehose/install/templates/firehose_controller.rb +16 -0
- metadata +39 -366
- data/.codeclimate.yml +0 -29
- data/.dockerignore +0 -2
- data/.env.sample +0 -17
- data/.gitignore +0 -14
- data/.rspec +0 -1
- data/.rubocop.yml +0 -1156
- data/.ruby-version +0 -1
- data/.travis.yml +0 -12
- data/Dockerfile +0 -11
- data/Gemfile +0 -6
- data/Procfile +0 -1
- data/Procfile.dev +0 -3
- data/Rakefile +0 -64
- data/bin/firehose +0 -9
- data/coffeelint.json +0 -129
- data/config/rainbows.rb +0 -17
- data/docker-compose.yml +0 -17
- data/firehose.gemspec +0 -45
- data/karma.config.coffee +0 -89
- data/lib/assets/javascripts/firehose/base.js.coffee +0 -4
- data/lib/assets/javascripts/firehose/consumer.js.coffee +0 -86
- data/lib/assets/javascripts/firehose/core.js.coffee +0 -6
- data/lib/assets/javascripts/firehose/long_poll.js.coffee +0 -210
- data/lib/assets/javascripts/firehose/multiplexed_consumer.js.coffee +0 -74
- data/lib/assets/javascripts/firehose/transport.js.coffee +0 -44
- data/lib/assets/javascripts/firehose/version.js.coffee.erb +0 -2
- data/lib/assets/javascripts/firehose/web_socket.js.coffee +0 -148
- data/lib/assets/javascripts/firehose.js.coffee +0 -2
- data/lib/firehose/assets.rb +0 -56
- data/lib/firehose/cli.rb +0 -79
- data/lib/firehose/client/consumer.rb +0 -94
- data/lib/firehose/client/producer.rb +0 -114
- data/lib/firehose/client.rb +0 -10
- data/lib/firehose/logging.rb +0 -32
- data/lib/firehose/rack/app.rb +0 -49
- data/lib/firehose/rack/consumer/http_long_poll.rb +0 -159
- data/lib/firehose/rack/consumer/web_socket.rb +0 -200
- data/lib/firehose/rack/consumer.rb +0 -78
- data/lib/firehose/rack/ping.rb +0 -88
- data/lib/firehose/rack/publisher.rb +0 -59
- data/lib/firehose/rack.rb +0 -32
- data/lib/firehose/rails.rb +0 -7
- data/lib/firehose/server/app.rb +0 -52
- data/lib/firehose/server/channel.rb +0 -72
- data/lib/firehose/server/message_buffer.rb +0 -59
- data/lib/firehose/server/publisher.rb +0 -133
- data/lib/firehose/server/redis.rb +0 -32
- data/lib/firehose/server/subscriber.rb +0 -51
- data/lib/firehose/version.rb +0 -4
- data/package.json +0 -17
- data/spec/integrations/integration_test_helper.rb +0 -22
- data/spec/integrations/rainbows_spec.rb +0 -7
- data/spec/integrations/shared_examples.rb +0 -202
- data/spec/integrations/thin_spec.rb +0 -7
- data/spec/javascripts/firehose/base_spec.coffee +0 -2
- data/spec/javascripts/firehose/consumer_spec.coffee +0 -45
- data/spec/javascripts/firehose/long_poll_spec.coffee +0 -44
- data/spec/javascripts/firehose/multiplexed_consumer_spec.coffee +0 -72
- data/spec/javascripts/firehose/transport_spec.coffee +0 -30
- data/spec/javascripts/firehose/websocket_spec.coffee +0 -27
- data/spec/javascripts/helpers/spec_helper.js +0 -31
- data/spec/javascripts/support/jquery-1.11.1.js +0 -10308
- data/spec/javascripts/support/json2.js +0 -487
- data/spec/javascripts/support/sinon-1.7.3.js +0 -4290
- data/spec/javascripts/support/spec_helper.coffee +0 -3
- data/spec/lib/assets_spec.rb +0 -35
- data/spec/lib/client/consumer_spec.rb +0 -13
- data/spec/lib/client/producer_spec.rb +0 -71
- data/spec/lib/firehose_spec.rb +0 -7
- data/spec/lib/rack/consumer/http_long_poll_spec.rb +0 -30
- data/spec/lib/rack/consumer_spec.rb +0 -19
- data/spec/lib/rack/ping_spec.rb +0 -28
- data/spec/lib/rack/publisher_spec.rb +0 -34
- data/spec/lib/server/app_spec.rb +0 -15
- data/spec/lib/server/channel_spec.rb +0 -178
- data/spec/lib/server/message_buffer_spec.rb +0 -148
- data/spec/lib/server/publisher_spec.rb +0 -91
- data/spec/lib/server/redis_spec.rb +0 -13
- data/spec/lib/server/subscriber_spec.rb +0 -70
- data/spec/spec_helper.rb +0 -84
data/.ruby-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2.3.0
|
data/.travis.yml
DELETED
data/Dockerfile
DELETED
data/Gemfile
DELETED
data/Procfile
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
firehose: ./bin/firehose server -p $PORT
|
data/Procfile.dev
DELETED
data/Rakefile
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
require "rake/testtask"
|
|
2
|
-
require 'bundler/gem_tasks'
|
|
3
|
-
require 'rspec/core/rake_task'
|
|
4
|
-
require 'coffee-script'
|
|
5
|
-
|
|
6
|
-
task :default => :spec
|
|
7
|
-
task :debug => ["spec:debug"]
|
|
8
|
-
task :ci => ["spec:ci"]
|
|
9
|
-
|
|
10
|
-
task :spec => ["spec:all"]
|
|
11
|
-
|
|
12
|
-
namespace :js do
|
|
13
|
-
desc "Compile *.js.coffee.erb files"
|
|
14
|
-
task :compile_erb do
|
|
15
|
-
require 'erb'
|
|
16
|
-
require_relative "lib/firehose"
|
|
17
|
-
|
|
18
|
-
erb_files = Dir.glob("lib/assets/javascripts/**/*.erb")
|
|
19
|
-
|
|
20
|
-
erb_files.each do |template_file|
|
|
21
|
-
output_file = template_file.split(".erb")[0]
|
|
22
|
-
puts "ERB compile #{template_file} => #{output_file}"
|
|
23
|
-
|
|
24
|
-
renderer = ERB.new File.read(template_file)
|
|
25
|
-
File.open(output_file, "w+") do |f|
|
|
26
|
-
f.puts renderer.result
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
namespace :spec do
|
|
33
|
-
desc "Run all specs"
|
|
34
|
-
task :all => [:ruby, "js:run"]
|
|
35
|
-
|
|
36
|
-
desc 'run Rspec specs'
|
|
37
|
-
task :ruby do
|
|
38
|
-
sh 'rspec spec'
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
task :js => "js:run"
|
|
42
|
-
|
|
43
|
-
# desc "Run specs with Karma runner"
|
|
44
|
-
namespace :js do
|
|
45
|
-
task :setup => "js:compile_erb" do
|
|
46
|
-
sh %[npm install]
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
desc "CI specs run on PhantomJS"
|
|
50
|
-
task :ci => :setup do
|
|
51
|
-
sh %[./node_modules/karma/bin/karma start karma.config.coffee --browsers PhantomJS --single-run --reporters dots,junit]
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
desc "Run local specs in PhantomJS"
|
|
55
|
-
task :run => :setup do
|
|
56
|
-
sh %[./node_modules/karma/bin/karma start karma.config.coffee --browsers PhantomJS --single-run]
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
desc "Run local specs in Chrome and leaves the window open for debugging"
|
|
60
|
-
task :debug => :setup do
|
|
61
|
-
sh %[./node_modules/karma/bin/karma start karma.config.coffee --browsers Chrome]
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
data/bin/firehose
DELETED
data/coffeelint.json
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"arrow_spacing": {
|
|
3
|
-
"level": "ignore"
|
|
4
|
-
},
|
|
5
|
-
"braces_spacing": {
|
|
6
|
-
"level": "ignore",
|
|
7
|
-
"spaces": 0,
|
|
8
|
-
"empty_object_spaces": 0
|
|
9
|
-
},
|
|
10
|
-
"camel_case_classes": {
|
|
11
|
-
"level": "error"
|
|
12
|
-
},
|
|
13
|
-
"coffeescript_error": {
|
|
14
|
-
"level": "error"
|
|
15
|
-
},
|
|
16
|
-
"colon_assignment_spacing": {
|
|
17
|
-
"level": "ignore",
|
|
18
|
-
"spacing": {
|
|
19
|
-
"left": 0,
|
|
20
|
-
"right": 0
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"cyclomatic_complexity": {
|
|
24
|
-
"value": 10,
|
|
25
|
-
"level": "ignore"
|
|
26
|
-
},
|
|
27
|
-
"duplicate_key": {
|
|
28
|
-
"level": "error"
|
|
29
|
-
},
|
|
30
|
-
"empty_constructor_needs_parens": {
|
|
31
|
-
"level": "ignore"
|
|
32
|
-
},
|
|
33
|
-
"ensure_comprehensions": {
|
|
34
|
-
"level": "warn"
|
|
35
|
-
},
|
|
36
|
-
"eol_last": {
|
|
37
|
-
"level": "ignore"
|
|
38
|
-
},
|
|
39
|
-
"indentation": {
|
|
40
|
-
"value": 2,
|
|
41
|
-
"level": "error"
|
|
42
|
-
},
|
|
43
|
-
"line_endings": {
|
|
44
|
-
"level": "ignore",
|
|
45
|
-
"value": "unix"
|
|
46
|
-
},
|
|
47
|
-
"max_line_length": {
|
|
48
|
-
"value": 80,
|
|
49
|
-
"level": "error",
|
|
50
|
-
"limitComments": true
|
|
51
|
-
},
|
|
52
|
-
"missing_fat_arrows": {
|
|
53
|
-
"level": "ignore",
|
|
54
|
-
"is_strict": false
|
|
55
|
-
},
|
|
56
|
-
"newlines_after_classes": {
|
|
57
|
-
"value": 3,
|
|
58
|
-
"level": "ignore"
|
|
59
|
-
},
|
|
60
|
-
"no_backticks": {
|
|
61
|
-
"level": "error"
|
|
62
|
-
},
|
|
63
|
-
"no_debugger": {
|
|
64
|
-
"level": "warn",
|
|
65
|
-
"console": false
|
|
66
|
-
},
|
|
67
|
-
"no_empty_functions": {
|
|
68
|
-
"level": "ignore"
|
|
69
|
-
},
|
|
70
|
-
"no_empty_param_list": {
|
|
71
|
-
"level": "ignore"
|
|
72
|
-
},
|
|
73
|
-
"no_implicit_braces": {
|
|
74
|
-
"level": "ignore",
|
|
75
|
-
"strict": true
|
|
76
|
-
},
|
|
77
|
-
"no_implicit_parens": {
|
|
78
|
-
"strict": true,
|
|
79
|
-
"level": "ignore"
|
|
80
|
-
},
|
|
81
|
-
"no_interpolation_in_single_quotes": {
|
|
82
|
-
"level": "ignore"
|
|
83
|
-
},
|
|
84
|
-
"no_plusplus": {
|
|
85
|
-
"level": "ignore"
|
|
86
|
-
},
|
|
87
|
-
"no_stand_alone_at": {
|
|
88
|
-
"level": "ignore"
|
|
89
|
-
},
|
|
90
|
-
"no_tabs": {
|
|
91
|
-
"level": "error"
|
|
92
|
-
},
|
|
93
|
-
"no_this": {
|
|
94
|
-
"level": "ignore"
|
|
95
|
-
},
|
|
96
|
-
"no_throwing_strings": {
|
|
97
|
-
"level": "error"
|
|
98
|
-
},
|
|
99
|
-
"no_trailing_semicolons": {
|
|
100
|
-
"level": "error"
|
|
101
|
-
},
|
|
102
|
-
"no_trailing_whitespace": {
|
|
103
|
-
"level": "error",
|
|
104
|
-
"allowed_in_comments": false,
|
|
105
|
-
"allowed_in_empty_lines": true
|
|
106
|
-
},
|
|
107
|
-
"no_unnecessary_double_quotes": {
|
|
108
|
-
"level": "ignore"
|
|
109
|
-
},
|
|
110
|
-
"no_unnecessary_fat_arrows": {
|
|
111
|
-
"level": "warn"
|
|
112
|
-
},
|
|
113
|
-
"non_empty_constructor_needs_parens": {
|
|
114
|
-
"level": "ignore"
|
|
115
|
-
},
|
|
116
|
-
"prefer_english_operator": {
|
|
117
|
-
"level": "ignore",
|
|
118
|
-
"doubleNotLevel": "ignore"
|
|
119
|
-
},
|
|
120
|
-
"space_operators": {
|
|
121
|
-
"level": "ignore"
|
|
122
|
-
},
|
|
123
|
-
"spacing_after_comma": {
|
|
124
|
-
"level": "ignore"
|
|
125
|
-
},
|
|
126
|
-
"transform_messes_up_line_numbers": {
|
|
127
|
-
"level": "warn"
|
|
128
|
-
}
|
|
129
|
-
}
|
data/config/rainbows.rb
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Configuration from http://rainbows.rubyforge.org/Rainbows/Configurator.html. Don't juse
|
|
2
|
-
# blindly copy and paste this configuration! Be sure you have read and understand the Rainbows
|
|
3
|
-
# configuration documentation for your environment.
|
|
4
|
-
|
|
5
|
-
Rainbows! do
|
|
6
|
-
use :EventMachine # concurrency model
|
|
7
|
-
worker_connections 400
|
|
8
|
-
keepalive_timeout 0 # disables keepalives
|
|
9
|
-
keepalive_requests 666 # default:100
|
|
10
|
-
client_max_body_size 5 * 1024 * 1024 # 5 megabytes
|
|
11
|
-
client_header_buffer_size 2 * 1024 # 2 kilobytes
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
# the rest of the Unicorn configuration...
|
|
15
|
-
worker_processes [ENV['WORKER_PROCESSES'].to_i, 1].max # Default to 1
|
|
16
|
-
working_directory ENV['WORKING_DIRECTORY'] if ENV['WORKING_DIRECTORY']
|
|
17
|
-
logger Firehose.logger
|
data/docker-compose.yml
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Isolated development and test environment.
|
|
2
|
-
version: '2'
|
|
3
|
-
services:
|
|
4
|
-
firehose:
|
|
5
|
-
build: .
|
|
6
|
-
depends_on:
|
|
7
|
-
- redis
|
|
8
|
-
environment:
|
|
9
|
-
REDIS_URL: redis://redis:6379/0
|
|
10
|
-
ports:
|
|
11
|
-
- 7474
|
|
12
|
-
volumes:
|
|
13
|
-
- .:/firehose/
|
|
14
|
-
redis:
|
|
15
|
-
image: redis
|
|
16
|
-
expose:
|
|
17
|
-
- 6379
|
data/firehose.gemspec
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
-
require "firehose/version"
|
|
4
|
-
|
|
5
|
-
Gem::Specification.new do |s|
|
|
6
|
-
s.name = "firehose"
|
|
7
|
-
s.version = Firehose::VERSION
|
|
8
|
-
s.authors = ["Brad Gessler", "Steel Fu", "Paul Cortens", "Zach Zolton", "Christopher Bertels"]
|
|
9
|
-
s.email = ["brad@polleverywhere.com", "steel@polleverywhere.com", "paul@polleverywhere.com", "zach@polleverywhere.com", "christopher@polleverywhere.com"]
|
|
10
|
-
s.homepage = "http://firehose.io/"
|
|
11
|
-
s.summary = %q{Build realtime Ruby web applications}
|
|
12
|
-
s.description = %q{Firehose is a realtime web application toolkit for building realtime Ruby web applications.}
|
|
13
|
-
s.license = "MIT"
|
|
14
|
-
|
|
15
|
-
s.rubyforge_project = "firehose"
|
|
16
|
-
|
|
17
|
-
s.files = `git ls-files`.split("\n")
|
|
18
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
19
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
20
|
-
s.require_paths = ["lib"]
|
|
21
|
-
|
|
22
|
-
# specify any dependencies here; for example:
|
|
23
|
-
s.add_runtime_dependency "eventmachine", ">= 1.0.0"
|
|
24
|
-
s.add_runtime_dependency "em-hiredis", ">= 0.2.0"
|
|
25
|
-
s.add_runtime_dependency "thor"
|
|
26
|
-
# faraday 0.9.1 causes some specs to fail
|
|
27
|
-
# need to investigate this further
|
|
28
|
-
s.add_runtime_dependency "faraday", "0.9.0"
|
|
29
|
-
s.add_runtime_dependency "faye-websocket"
|
|
30
|
-
s.add_runtime_dependency "em-http-request", ">= 1.0.0"
|
|
31
|
-
s.add_runtime_dependency "rack"
|
|
32
|
-
|
|
33
|
-
s.add_development_dependency "rspec", "~> 2"
|
|
34
|
-
s.add_development_dependency "webmock"
|
|
35
|
-
s.add_development_dependency "coffee-script"
|
|
36
|
-
s.add_development_dependency "rainbows", "~> 4.4.3"
|
|
37
|
-
s.add_development_dependency "thin"
|
|
38
|
-
s.add_development_dependency "rack-test"
|
|
39
|
-
s.add_development_dependency "async_rack_test"
|
|
40
|
-
s.add_development_dependency "foreman"
|
|
41
|
-
s.add_development_dependency "sprockets"
|
|
42
|
-
s.add_development_dependency "rake"
|
|
43
|
-
s.add_development_dependency "capybara-webkit"
|
|
44
|
-
s.add_development_dependency "therubyracer"
|
|
45
|
-
end
|
data/karma.config.coffee
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# Karma configuration
|
|
2
|
-
# Generated on Mon Jul 07 2014 12:32:37 GMT-0700 (PDT)
|
|
3
|
-
module.exports = (config) ->
|
|
4
|
-
config.set
|
|
5
|
-
# base path that will be used to resolve all patterns (eg. files, exclude)
|
|
6
|
-
basePath: ""
|
|
7
|
-
|
|
8
|
-
# frameworks to use
|
|
9
|
-
# available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
|
10
|
-
frameworks: [
|
|
11
|
-
"sprockets-mincer"
|
|
12
|
-
"jasmine"
|
|
13
|
-
]
|
|
14
|
-
|
|
15
|
-
# list of files / patterns to load in the browser
|
|
16
|
-
files: []
|
|
17
|
-
|
|
18
|
-
# list of files to exclude
|
|
19
|
-
exclude: []
|
|
20
|
-
|
|
21
|
-
# preprocess matching files before serving them to the browser
|
|
22
|
-
# available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
|
23
|
-
preprocessors:
|
|
24
|
-
"**/*.coffee": ["coffee"]
|
|
25
|
-
|
|
26
|
-
# test results reporter to use
|
|
27
|
-
# possible values: 'dots', 'progress'
|
|
28
|
-
# available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
|
29
|
-
reporters: ["progress", "dots"]
|
|
30
|
-
|
|
31
|
-
# web server port
|
|
32
|
-
port: 9876
|
|
33
|
-
|
|
34
|
-
# enable / disable colors in the output (reporters and logs)
|
|
35
|
-
colors: true
|
|
36
|
-
|
|
37
|
-
# level of logging
|
|
38
|
-
# possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
|
39
|
-
logLevel: config.LOG_INFO
|
|
40
|
-
|
|
41
|
-
# enable / disable watching file and executing tests whenever any file changes
|
|
42
|
-
autoWatch: true
|
|
43
|
-
|
|
44
|
-
# start these browsers
|
|
45
|
-
# available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
|
46
|
-
browsers: ["Chrome", "PhantomJS"]
|
|
47
|
-
|
|
48
|
-
# Continuous Integration mode
|
|
49
|
-
# if true, Karma captures browsers, runs the tests and exits
|
|
50
|
-
singleRun: false
|
|
51
|
-
|
|
52
|
-
plugins: [
|
|
53
|
-
"karma-jasmine"
|
|
54
|
-
"karma-chrome-launcher"
|
|
55
|
-
"karma-coffee-preprocessor"
|
|
56
|
-
"karma-sprockets-mincer"
|
|
57
|
-
"karma-phantomjs-launcher"
|
|
58
|
-
"karma-junit-reporter"
|
|
59
|
-
]
|
|
60
|
-
|
|
61
|
-
sprocketsPaths: [
|
|
62
|
-
"lib/assets/javascripts"
|
|
63
|
-
"spec/javascripts"
|
|
64
|
-
]
|
|
65
|
-
|
|
66
|
-
sprocketsBundles: [
|
|
67
|
-
"support/spec_helper.coffee"
|
|
68
|
-
"firehose.js.coffee"
|
|
69
|
-
]
|
|
70
|
-
|
|
71
|
-
# The spec files to run and watch changes for
|
|
72
|
-
files: [
|
|
73
|
-
'spec/javascripts/**/*_spec.coffee'
|
|
74
|
-
]
|
|
75
|
-
|
|
76
|
-
junitReporter: {
|
|
77
|
-
outputFile: 'tmp/spec-results.xml',
|
|
78
|
-
suite: ''
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
coffeePreprocessor:
|
|
82
|
-
# options passed to the coffee compiler
|
|
83
|
-
options:
|
|
84
|
-
bare: true
|
|
85
|
-
sourceMap: false
|
|
86
|
-
|
|
87
|
-
# transforming the filenames
|
|
88
|
-
transformPath: (path) ->
|
|
89
|
-
path.replace /\.js\.coffee$/, ".js"
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
class Firehose.Consumer
|
|
2
|
-
constructor: (@config = {}) ->
|
|
3
|
-
# Empty handler for messages.
|
|
4
|
-
@config.message ||= ->
|
|
5
|
-
# Empty handler for error handling.
|
|
6
|
-
@config.error ||= ->
|
|
7
|
-
# Empty handler for when we establish a connection.
|
|
8
|
-
@config.connected ||= ->
|
|
9
|
-
# Empty handler for when we're disconnected.
|
|
10
|
-
@config.disconnected ||= ->
|
|
11
|
-
# The initial connection failed. This is probably triggered when a
|
|
12
|
-
# transport, like WebSockets is supported by the browser, but for whatever
|
|
13
|
-
# reason it can't connect (probably a firewall)
|
|
14
|
-
@config.failed ||= ->
|
|
15
|
-
throw "Could not connect"
|
|
16
|
-
# Params that we'll tack on to the URL.
|
|
17
|
-
@config.params ||= {}
|
|
18
|
-
# Do stuff before we send the message into config.message. The sensible
|
|
19
|
-
# default on the webs is to parse JSON.
|
|
20
|
-
@config.parse ||= JSON.parse
|
|
21
|
-
|
|
22
|
-
@_isConnected = false
|
|
23
|
-
origConnected = @config.connected
|
|
24
|
-
@config.connected = =>
|
|
25
|
-
@_isConnected = true
|
|
26
|
-
origConnected()
|
|
27
|
-
|
|
28
|
-
# Make sure we return ourself out of the constructor so we can chain.
|
|
29
|
-
this
|
|
30
|
-
|
|
31
|
-
connected: =>
|
|
32
|
-
@_isConnected
|
|
33
|
-
|
|
34
|
-
websocketTransport: (config) =>
|
|
35
|
-
new Firehose.WebSocket(config)
|
|
36
|
-
|
|
37
|
-
longpollTransport: (config) =>
|
|
38
|
-
new Firehose.LongPoll(config)
|
|
39
|
-
|
|
40
|
-
connect: (delay=0) =>
|
|
41
|
-
promise = @_connectPromise()
|
|
42
|
-
|
|
43
|
-
@config.connectionVerified = @_upgradeTransport
|
|
44
|
-
if Firehose.WebSocket.supported()
|
|
45
|
-
@upgradeTimeout = setTimeout =>
|
|
46
|
-
ws = @websocketTransport(@config)
|
|
47
|
-
ws.connect delay
|
|
48
|
-
, 500
|
|
49
|
-
@transport = @longpollTransport(@config)
|
|
50
|
-
@transport.connect delay
|
|
51
|
-
|
|
52
|
-
promise
|
|
53
|
-
|
|
54
|
-
stop: =>
|
|
55
|
-
if @upgradeTimeout?
|
|
56
|
-
clearTimeout @upgradeTimeout
|
|
57
|
-
@upgradeTimeout = null
|
|
58
|
-
@transport.stop()
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
_upgradeTransport: (ws) =>
|
|
62
|
-
@transport.stop()
|
|
63
|
-
ws.sendStartingMessageSequence @transport.getLastMessageSequence()
|
|
64
|
-
@transport = ws
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
# Return a promise that will succeed/fail depending on whether or not the
|
|
68
|
-
# initial connection succeeds.
|
|
69
|
-
_connectPromise: =>
|
|
70
|
-
deferred = $.Deferred()
|
|
71
|
-
|
|
72
|
-
origConnected = @config.connected
|
|
73
|
-
@config.connected = =>
|
|
74
|
-
deferred.resolve()
|
|
75
|
-
if origConnected
|
|
76
|
-
@config.connected = origConnected
|
|
77
|
-
origConnected()
|
|
78
|
-
|
|
79
|
-
# origDisconnected = @config.disconnected
|
|
80
|
-
# @config.disconnected = =>
|
|
81
|
-
# deferred.reject()
|
|
82
|
-
# if origDisconnected
|
|
83
|
-
# @config.disconnected = origDisconnected
|
|
84
|
-
# origDisconnected()
|
|
85
|
-
|
|
86
|
-
deferred.promise()
|