litecable 0.4.1 → 0.7.1
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 +34 -1
- data/LICENSE.txt +1 -1
- data/README.md +30 -28
- data/lib/lite_cable.rb +23 -2
- data/lib/lite_cable/anycable.rb +23 -14
- data/lib/lite_cable/broadcast_adapters.rb +35 -0
- data/lib/lite_cable/broadcast_adapters/any_cable.rb +11 -0
- data/lib/lite_cable/broadcast_adapters/base.rb +17 -0
- data/lib/lite_cable/broadcast_adapters/memory.rb +11 -0
- data/lib/lite_cable/channel.rb +1 -0
- data/lib/lite_cable/channel/base.rb +4 -2
- data/lib/lite_cable/channel/registry.rb +5 -0
- data/lib/lite_cable/channel/streams.rb +1 -2
- data/lib/lite_cable/coders.rb +1 -0
- data/lib/lite_cable/coders/json.rb +1 -0
- data/lib/lite_cable/coders/raw.rb +2 -1
- data/lib/lite_cable/config.rb +8 -6
- data/lib/lite_cable/connection.rb +1 -0
- data/lib/lite_cable/connection/authorization.rb +1 -0
- data/lib/lite_cable/connection/base.rb +2 -2
- data/lib/lite_cable/connection/identification.rb +3 -0
- data/lib/lite_cable/connection/streams.rb +1 -0
- data/lib/lite_cable/connection/subscriptions.rb +7 -2
- data/lib/lite_cable/internal.rb +1 -0
- data/lib/lite_cable/logging.rb +4 -2
- data/lib/lite_cable/server.rb +1 -6
- data/lib/lite_cable/server/client_socket.rb +1 -0
- data/lib/lite_cable/server/client_socket/base.rb +17 -21
- data/lib/lite_cable/server/client_socket/subscriptions.rb +3 -2
- data/lib/lite_cable/server/heart_beat.rb +4 -1
- data/lib/lite_cable/server/middleware.rb +7 -6
- data/lib/lite_cable/server/subscribers_map.rb +3 -0
- data/lib/lite_cable/version.rb +2 -1
- data/lib/litecable.rb +1 -0
- metadata +31 -77
- data/.gitignore +0 -40
- data/.rubocop.yml +0 -63
- data/.travis.yml +0 -7
- data/Gemfile +0 -4
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/circle.yml +0 -8
- data/examples/sinatra/Gemfile +0 -16
- data/examples/sinatra/Procfile +0 -3
- data/examples/sinatra/README.md +0 -33
- data/examples/sinatra/anycable +0 -18
- data/examples/sinatra/app.rb +0 -52
- data/examples/sinatra/assets/app.css +0 -169
- data/examples/sinatra/assets/cable.js +0 -584
- data/examples/sinatra/assets/reset.css +0 -223
- data/examples/sinatra/bin/anycable-go +0 -0
- data/examples/sinatra/chat.rb +0 -39
- data/examples/sinatra/config.ru +0 -28
- data/examples/sinatra/views/index.slim +0 -8
- data/examples/sinatra/views/layout.slim +0 -15
- data/examples/sinatra/views/login.slim +0 -8
- data/examples/sinatra/views/resetcss.slim +0 -224
- data/examples/sinatra/views/room.slim +0 -68
- data/litecable.gemspec +0 -33
data/.gitignore
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# Numerous always-ignore extensions
|
2
|
-
*.diff
|
3
|
-
*.err
|
4
|
-
*.orig
|
5
|
-
*.log
|
6
|
-
*.rej
|
7
|
-
*.swo
|
8
|
-
*.swp
|
9
|
-
*.vi
|
10
|
-
*~
|
11
|
-
*.sass-cache
|
12
|
-
*.iml
|
13
|
-
.idea/
|
14
|
-
|
15
|
-
# Sublime
|
16
|
-
*.sublime-project
|
17
|
-
*.sublime-workspace
|
18
|
-
|
19
|
-
# OS or Editor folders
|
20
|
-
.DS_Store
|
21
|
-
.cache
|
22
|
-
.project
|
23
|
-
.settings
|
24
|
-
.tmproj
|
25
|
-
Thumbs.db
|
26
|
-
|
27
|
-
.bundle/
|
28
|
-
log/*.log
|
29
|
-
*.gz
|
30
|
-
pkg/
|
31
|
-
spec/dummy/db/*.sqlite3
|
32
|
-
spec/dummy/db/*.sqlite3-journal
|
33
|
-
spec/dummy/tmp/
|
34
|
-
|
35
|
-
Gemfile.lock
|
36
|
-
Gemfile.local
|
37
|
-
.rspec
|
38
|
-
*.gem
|
39
|
-
tmp/
|
40
|
-
coverage/
|
data/.rubocop.yml
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
# Include gemspec and Rakefile
|
3
|
-
Include:
|
4
|
-
- 'lib/**/*.rb'
|
5
|
-
- 'lib/**/*.rake'
|
6
|
-
- 'spec/**/*.rb'
|
7
|
-
Exclude:
|
8
|
-
- 'bin/**/*'
|
9
|
-
- 'spec/dummy/**/*'
|
10
|
-
- 'tmp/**/*'
|
11
|
-
- 'bench/**/*'
|
12
|
-
- 'lib/anycable/rpc/**/*'
|
13
|
-
DisplayCopNames: true
|
14
|
-
StyleGuideCopsOnly: false
|
15
|
-
TargetRubyVersion: 2.3
|
16
|
-
|
17
|
-
Style/AccessorMethodName:
|
18
|
-
Enabled: false
|
19
|
-
|
20
|
-
Style/TrivialAccessors:
|
21
|
-
Enabled: false
|
22
|
-
|
23
|
-
Style/Documentation:
|
24
|
-
Exclude:
|
25
|
-
- 'spec/**/*.rb'
|
26
|
-
|
27
|
-
Style/ParallelAssignment:
|
28
|
-
Enabled: false
|
29
|
-
|
30
|
-
Style/StringLiterals:
|
31
|
-
Enabled: false
|
32
|
-
|
33
|
-
Style/SpaceInsideStringInterpolation:
|
34
|
-
EnforcedStyle: no_space
|
35
|
-
|
36
|
-
Style/BlockDelimiters:
|
37
|
-
Exclude:
|
38
|
-
- 'spec/**/*.rb'
|
39
|
-
|
40
|
-
Lint/AmbiguousRegexpLiteral:
|
41
|
-
Enabled: false
|
42
|
-
|
43
|
-
Lint/AssignmentInCondition:
|
44
|
-
Enabled: false
|
45
|
-
|
46
|
-
Metrics/MethodLength:
|
47
|
-
Exclude:
|
48
|
-
- 'spec/**/*.rb'
|
49
|
-
|
50
|
-
Metrics/LineLength:
|
51
|
-
Max: 100
|
52
|
-
Exclude:
|
53
|
-
- 'spec/**/*.rb'
|
54
|
-
|
55
|
-
Metrics/BlockLength:
|
56
|
-
Exclude:
|
57
|
-
- 'spec/**/*.rb'
|
58
|
-
|
59
|
-
Rails/Date:
|
60
|
-
Enabled: false
|
61
|
-
|
62
|
-
Rails/TimeZone:
|
63
|
-
Enabled: false
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "litecable"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
data/bin/setup
DELETED
data/circle.yml
DELETED
data/examples/sinatra/Gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'sinatra'
|
4
|
-
gem 'sinatra-contrib'
|
5
|
-
gem 'slim'
|
6
|
-
|
7
|
-
gem 'puma'
|
8
|
-
|
9
|
-
gem 'pry-byebug'
|
10
|
-
|
11
|
-
# litecable deps
|
12
|
-
gem "anyway_config", "~> 0.5.0"
|
13
|
-
gem "websocket", "~> 1.2.4"
|
14
|
-
|
15
|
-
# anycable
|
16
|
-
gem "anycable", "~> 0.4.2"
|
data/examples/sinatra/Procfile
DELETED
data/examples/sinatra/README.md
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# Lite Cable Sinatra Demo
|
2
|
-
|
3
|
-
Sample chat application built with [Sinatra](http://www.sinatrarb.com) and Lite Cable.
|
4
|
-
|
5
|
-
## Usage
|
6
|
-
|
7
|
-
Install dependencies:
|
8
|
-
|
9
|
-
```sh
|
10
|
-
bundle install
|
11
|
-
```
|
12
|
-
|
13
|
-
Run server:
|
14
|
-
|
15
|
-
```sh
|
16
|
-
bundle exec puma
|
17
|
-
```
|
18
|
-
|
19
|
-
Open your browser at [localhost:9292](http://localhost:9292), enter your name and a chat room ID (anything you want).
|
20
|
-
|
21
|
-
Then open another session (another browser, incognito window) and repeat all steps using the same room ID.
|
22
|
-
|
23
|
-
Now you can chat with yourself!
|
24
|
-
|
25
|
-
## AnyCable usage
|
26
|
-
|
27
|
-
This example also can be used with [AnyCable](http://anycable.io).
|
28
|
-
|
29
|
-
Just run `Procfile` with your favourite tool ([hivemind](https://github.com/DarthSim/hivemind) or [Foreman](http://ddollar.github.io/foreman/)):
|
30
|
-
|
31
|
-
```sh
|
32
|
-
hivemind
|
33
|
-
```
|
data/examples/sinatra/anycable
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
lib = File.expand_path("../../../lib", __FILE__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
|
6
|
-
require "./chat"
|
7
|
-
require "rack"
|
8
|
-
require "anycable"
|
9
|
-
|
10
|
-
# Turn AnyCable compatibility mode
|
11
|
-
LiteCable.anycable!
|
12
|
-
|
13
|
-
Anycable.configure do |config|
|
14
|
-
config.connection_factory = Chat::Connection
|
15
|
-
config.debug = true
|
16
|
-
end
|
17
|
-
|
18
|
-
Anycable::Server.start
|
data/examples/sinatra/app.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "sinatra"
|
3
|
-
require "sinatra/cookies"
|
4
|
-
|
5
|
-
CABLE_URL = ENV['ANYCABLE'] ? "ws://localhost:9293/cable" : "/cable"
|
6
|
-
|
7
|
-
class App < Sinatra::Application # :nodoc:
|
8
|
-
set :public_folder, 'assets'
|
9
|
-
|
10
|
-
enable :sessions
|
11
|
-
set :session_secret, 'my_secrets'
|
12
|
-
|
13
|
-
get '/' do
|
14
|
-
if session[:user]
|
15
|
-
slim :index
|
16
|
-
else
|
17
|
-
slim :login
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
get '/sign_in' do
|
22
|
-
slim :login
|
23
|
-
end
|
24
|
-
|
25
|
-
post '/sign_in' do
|
26
|
-
if params['user']
|
27
|
-
session[:user] = params['user']
|
28
|
-
cookies["user"] = params['user']
|
29
|
-
redirect '/'
|
30
|
-
else
|
31
|
-
slim :login
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
post '/rooms' do
|
36
|
-
if params['id']
|
37
|
-
redirect "/rooms/#{params['id']}"
|
38
|
-
else
|
39
|
-
slim :index
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
get '/rooms/:id' do
|
44
|
-
if session[:user]
|
45
|
-
@room_id = params['id']
|
46
|
-
@user = session[:user]
|
47
|
-
slim :room
|
48
|
-
else
|
49
|
-
slim :login
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,169 +0,0 @@
|
|
1
|
-
html, body {
|
2
|
-
height: 100%;
|
3
|
-
width: 100%;
|
4
|
-
min-width: 300px;
|
5
|
-
}
|
6
|
-
|
7
|
-
body {
|
8
|
-
background: #fff;
|
9
|
-
color: #363636;
|
10
|
-
font: 18px/30px "Arial", sans-serif;
|
11
|
-
}
|
12
|
-
|
13
|
-
p, div, span, a, ul, li {
|
14
|
-
box-sizing: border-box;
|
15
|
-
}
|
16
|
-
|
17
|
-
a {
|
18
|
-
text-decoration: none;
|
19
|
-
color: #ff5e5e;
|
20
|
-
|
21
|
-
&:visited,
|
22
|
-
&:active {
|
23
|
-
color: #ff5e5e;
|
24
|
-
}
|
25
|
-
|
26
|
-
&:hover {
|
27
|
-
opacity: 0.8;
|
28
|
-
}
|
29
|
-
}
|
30
|
-
|
31
|
-
h1 {
|
32
|
-
font-size: 70px;
|
33
|
-
line-height: 90px;
|
34
|
-
letter-spacing: 2px;
|
35
|
-
font-weight: bold;
|
36
|
-
}
|
37
|
-
|
38
|
-
h2 {
|
39
|
-
font-size: 40px;
|
40
|
-
line-height: 50px;
|
41
|
-
letter-spacing: 1.5px;
|
42
|
-
margin: 20px 0;
|
43
|
-
}
|
44
|
-
|
45
|
-
.main {
|
46
|
-
height: 100%;
|
47
|
-
width: 100%;
|
48
|
-
padding: 0 20%;
|
49
|
-
}
|
50
|
-
|
51
|
-
.header {
|
52
|
-
width: 100%;
|
53
|
-
display: flex;
|
54
|
-
justify-content: center;
|
55
|
-
}
|
56
|
-
|
57
|
-
input[type="text"] {
|
58
|
-
width: 100%;
|
59
|
-
height: 40px;
|
60
|
-
line-height: 40px;
|
61
|
-
display: block;
|
62
|
-
margin: 0;
|
63
|
-
font-size: 18px;
|
64
|
-
appearance: none;
|
65
|
-
box-shadow: none;
|
66
|
-
border-radius: none;
|
67
|
-
}
|
68
|
-
|
69
|
-
button:focus, input[type="text"]:focus {
|
70
|
-
outline: none;
|
71
|
-
}
|
72
|
-
|
73
|
-
.btn {
|
74
|
-
cursor: pointer;
|
75
|
-
height: 40px;
|
76
|
-
text-decoration: none;
|
77
|
-
padding: 0 20px;
|
78
|
-
text-align: center;
|
79
|
-
background: #ff5e5e;
|
80
|
-
transition: opacity 200ms;
|
81
|
-
color: white;
|
82
|
-
font-weight: bold;
|
83
|
-
font-size: 16px;
|
84
|
-
letter-spacing: 1.5px;
|
85
|
-
display: flex;
|
86
|
-
align-items: center;
|
87
|
-
justify-content: center;
|
88
|
-
width: 100px;
|
89
|
-
margin-top: 30px;
|
90
|
-
}
|
91
|
-
|
92
|
-
.btn:hover {
|
93
|
-
opacity: 0.8;
|
94
|
-
}
|
95
|
-
|
96
|
-
.message-form {
|
97
|
-
position: fixed;
|
98
|
-
bottom: 0;
|
99
|
-
left: 0;
|
100
|
-
width: 100%;
|
101
|
-
border-top: 1px #e3e3e3 solid;
|
102
|
-
z-index: 10;
|
103
|
-
padding: 20px 20% 20px 20%;
|
104
|
-
background: white;
|
105
|
-
opacity: 0.9;
|
106
|
-
}
|
107
|
-
|
108
|
-
.messages {
|
109
|
-
display: flex;
|
110
|
-
flex-direction: column;
|
111
|
-
padding-bottom: 160px;
|
112
|
-
}
|
113
|
-
|
114
|
-
.message {
|
115
|
-
display: flex;
|
116
|
-
flex-direction: column;
|
117
|
-
}
|
118
|
-
|
119
|
-
.message.me {
|
120
|
-
align-self: flex-end;
|
121
|
-
}
|
122
|
-
|
123
|
-
.messages .message .author {
|
124
|
-
color: #ff5e5e;
|
125
|
-
}
|
126
|
-
|
127
|
-
.messages .message.me .author {
|
128
|
-
align-self: flex-end;
|
129
|
-
color: #7ed321;
|
130
|
-
}
|
131
|
-
|
132
|
-
.messages .message.system .author {
|
133
|
-
color: #9e9e9e;
|
134
|
-
}
|
135
|
-
|
136
|
-
@media (max-width: 800px) and (min-width: 601px) {
|
137
|
-
body {
|
138
|
-
font-size: 3vw;
|
139
|
-
line-height: 5vw;
|
140
|
-
}
|
141
|
-
|
142
|
-
h1 {
|
143
|
-
font-size: 14vw;
|
144
|
-
line-height: 18vw;
|
145
|
-
}
|
146
|
-
|
147
|
-
h2 {
|
148
|
-
font-size: 5vw;
|
149
|
-
line-height: 7vw;
|
150
|
-
}
|
151
|
-
}
|
152
|
-
|
153
|
-
|
154
|
-
@media (max-width: 600px) {
|
155
|
-
body {
|
156
|
-
font-size: 4vw;
|
157
|
-
line-height: 6vw;
|
158
|
-
}
|
159
|
-
|
160
|
-
h1 {
|
161
|
-
font-size: 14vw;
|
162
|
-
line-height: 18vw;
|
163
|
-
}
|
164
|
-
|
165
|
-
h2 {
|
166
|
-
font-size: 10vw;
|
167
|
-
line-height: 12vw;
|
168
|
-
}
|
169
|
-
}
|