litecable 0.4.2 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +38 -1
- data/LICENSE.txt +1 -1
- data/README.md +27 -28
- data/lib/lite_cable.rb +23 -2
- data/lib/lite_cable/anycable.rb +22 -13
- 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 +10 -5
- 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 +28 -75
- data/.gem_release.yml +0 -3
- 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
@@ -1,68 +0,0 @@
|
|
1
|
-
h2 ="Room: #{@room_id}"
|
2
|
-
|
3
|
-
.messages#message_list
|
4
|
-
|
5
|
-
.message-form
|
6
|
-
form#message_form
|
7
|
-
.row
|
8
|
-
input#message_txt type="text" required="required"
|
9
|
-
.row
|
10
|
-
button.btn type="submit"
|
11
|
-
span Send!
|
12
|
-
|
13
|
-
javascript:
|
14
|
-
var roomId = "#{{ @room_id }}";
|
15
|
-
var user = "#{{ @user }}";
|
16
|
-
var socketId = Date.now();
|
17
|
-
|
18
|
-
var messageList = document.getElementById("message_list");
|
19
|
-
var messageForm = document.getElementById("message_form");
|
20
|
-
var textInput = document.getElementById("message_txt");
|
21
|
-
|
22
|
-
messageForm.onsubmit = function(e){
|
23
|
-
e.preventDefault();
|
24
|
-
var msg = textInput.value;
|
25
|
-
console.log("Send message", msg);
|
26
|
-
textInput.value = null;
|
27
|
-
chatChannel.perform('speak', { message: msg });
|
28
|
-
};
|
29
|
-
|
30
|
-
var escape = function(str) {
|
31
|
-
return ('' + str).replace(/&/g, '&')
|
32
|
-
.replace(/</g, '<')
|
33
|
-
.replace(/>/g, '>')
|
34
|
-
.replace(/"/g, '"');
|
35
|
-
}
|
36
|
-
|
37
|
-
var addMessage = function(data){
|
38
|
-
var node = document.createElement('div');
|
39
|
-
var me = data['user'] == user && data['sid'] == socketId
|
40
|
-
node.className = "message" + (me ? ' me' : '') + (data['system'] ? ' system' : '');
|
41
|
-
node.innerHTML =
|
42
|
-
'<div class="author">' + escape(data['user']) + '</div>' +
|
43
|
-
'<div class="txt">' + escape(data['message']) + '</div>';
|
44
|
-
messageList.appendChild(node);
|
45
|
-
};
|
46
|
-
|
47
|
-
ActionCable.startDebugging();
|
48
|
-
var cable = ActionCable.createConsumer('#{{ CABLE_URL }}?sid=' + socketId);
|
49
|
-
|
50
|
-
var chatChannel = cable.subscriptions.create(
|
51
|
-
{ channel: 'chat', id: roomId },
|
52
|
-
{
|
53
|
-
connected: function(){
|
54
|
-
console.log("Connected");
|
55
|
-
addMessage({ user: 'BOT', message: "I'm connected", system: true });
|
56
|
-
},
|
57
|
-
|
58
|
-
disconnected: function(){
|
59
|
-
console.log("Connected");
|
60
|
-
addMessage({ user: 'BOT', message: "Sorry, but you've been disconnected(", system: true });
|
61
|
-
},
|
62
|
-
|
63
|
-
received: function(data){
|
64
|
-
console.log("Received", data);
|
65
|
-
addMessage(data);
|
66
|
-
}
|
67
|
-
}
|
68
|
-
)
|
data/litecable.gemspec
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'lite_cable/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "litecable"
|
8
|
-
spec.version = LiteCable::VERSION
|
9
|
-
spec.authors = ["palkan"]
|
10
|
-
spec.email = ["dementiev.vm@gmail.com"]
|
11
|
-
|
12
|
-
spec.summary = %q{Fat-free ActionCable implementation}
|
13
|
-
spec.description = %q{Fat-free ActionCable implementation for using with AnyCable (and without Rails)}
|
14
|
-
spec.homepage = "https://github.com/anycable/litecable"
|
15
|
-
spec.license = "MIT"
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.require_paths = ["lib"]
|
19
|
-
|
20
|
-
spec.add_dependency "anyway_config", "~> 1.0"
|
21
|
-
|
22
|
-
spec.add_development_dependency "rack", "~> 2.0"
|
23
|
-
spec.add_development_dependency "websocket", "~> 1.2.4"
|
24
|
-
spec.add_development_dependency "websocket-client-simple", "~> 0.3.0"
|
25
|
-
spec.add_development_dependency "concurrent-ruby", "~> 1.0.0"
|
26
|
-
spec.add_development_dependency "puma", "~> 3.6"
|
27
|
-
|
28
|
-
spec.add_development_dependency "bundler", "~> 1.13"
|
29
|
-
spec.add_development_dependency "rake", ">= 10.0"
|
30
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
-
spec.add_development_dependency "simplecov", ">= 0.3.8"
|
32
|
-
spec.add_development_dependency "pry-byebug"
|
33
|
-
end
|