litecable 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/LICENSE.txt +1 -1
- data/README.md +24 -22
- data/lib/lite_cable.rb +22 -2
- data/lib/lite_cable/anycable.rb +14 -12
- 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/config.rb +5 -4
- data/lib/lite_cable/connection/subscriptions.rb +2 -2
- data/lib/lite_cable/server.rb +0 -6
- data/lib/lite_cable/server/client_socket/base.rb +9 -15
- data/lib/lite_cable/version.rb +1 -1
- metadata +18 -76
- data/.gem_release.yml +0 -3
- data/.gitignore +0 -40
- data/.rubocop.yml +0 -53
- data/.travis.yml +0 -16
- data/Gemfile +0 -4
- data/Rakefile +0 -10
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/examples/sinatra/Gemfile +0 -19
- data/examples/sinatra/Procfile +0 -3
- data/examples/sinatra/README.md +0 -35
- data/examples/sinatra/app.rb +0 -53
- 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/chat.rb +0 -40
- data/examples/sinatra/config.ru +0 -21
- data/examples/sinatra/config/environment.rb +0 -18
- 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 -39
@@ -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,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
lib = File.expand_path("../lib", __FILE__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require "lite_cable/version"
|
6
|
-
|
7
|
-
Gem::Specification.new do |spec|
|
8
|
-
spec.name = "litecable"
|
9
|
-
spec.version = LiteCable::VERSION
|
10
|
-
spec.authors = ["palkan"]
|
11
|
-
spec.email = ["dementiev.vm@gmail.com"]
|
12
|
-
|
13
|
-
spec.summary = "Fat-free ActionCable implementation"
|
14
|
-
spec.description = "Fat-free ActionCable implementation for using with AnyCable (and without Rails)"
|
15
|
-
spec.homepage = "https://github.com/palkan/litecable"
|
16
|
-
spec.license = "MIT"
|
17
|
-
|
18
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.required_ruby_version = ">= 2.4.0"
|
22
|
-
|
23
|
-
spec.add_dependency "anyway_config", ">= 1.0"
|
24
|
-
|
25
|
-
spec.add_development_dependency "rack", "~> 2.0"
|
26
|
-
spec.add_development_dependency "websocket", "~> 1.2.4"
|
27
|
-
spec.add_development_dependency "websocket-client-simple", "~> 0.3.0"
|
28
|
-
spec.add_development_dependency "concurrent-ruby", "~> 1.0.0"
|
29
|
-
spec.add_development_dependency "puma", "~> 3.6"
|
30
|
-
|
31
|
-
spec.add_development_dependency "bundler", ">= 1.13"
|
32
|
-
spec.add_development_dependency "rake", ">= 10.0"
|
33
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
34
|
-
spec.add_development_dependency "simplecov", ">= 0.3.8"
|
35
|
-
spec.add_development_dependency "rubocop", "~> 0.65.0"
|
36
|
-
spec.add_development_dependency "rubocop-md", "~> 0.2"
|
37
|
-
spec.add_development_dependency "standard", "~> 0.0.36"
|
38
|
-
spec.add_development_dependency "pry-byebug"
|
39
|
-
end
|