litecable 0.4.2 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +38 -1
  3. data/LICENSE.txt +1 -1
  4. data/README.md +27 -28
  5. data/lib/lite_cable.rb +23 -2
  6. data/lib/lite_cable/anycable.rb +22 -13
  7. data/lib/lite_cable/broadcast_adapters.rb +35 -0
  8. data/lib/lite_cable/broadcast_adapters/any_cable.rb +11 -0
  9. data/lib/lite_cable/broadcast_adapters/base.rb +17 -0
  10. data/lib/lite_cable/broadcast_adapters/memory.rb +11 -0
  11. data/lib/lite_cable/channel.rb +1 -0
  12. data/lib/lite_cable/channel/base.rb +4 -2
  13. data/lib/lite_cable/channel/registry.rb +5 -0
  14. data/lib/lite_cable/channel/streams.rb +1 -2
  15. data/lib/lite_cable/coders.rb +1 -0
  16. data/lib/lite_cable/coders/json.rb +1 -0
  17. data/lib/lite_cable/coders/raw.rb +2 -1
  18. data/lib/lite_cable/config.rb +8 -6
  19. data/lib/lite_cable/connection.rb +1 -0
  20. data/lib/lite_cable/connection/authorization.rb +1 -0
  21. data/lib/lite_cable/connection/base.rb +2 -2
  22. data/lib/lite_cable/connection/identification.rb +3 -0
  23. data/lib/lite_cable/connection/streams.rb +1 -0
  24. data/lib/lite_cable/connection/subscriptions.rb +10 -5
  25. data/lib/lite_cable/internal.rb +1 -0
  26. data/lib/lite_cable/logging.rb +4 -2
  27. data/lib/lite_cable/server.rb +1 -6
  28. data/lib/lite_cable/server/client_socket.rb +1 -0
  29. data/lib/lite_cable/server/client_socket/base.rb +17 -21
  30. data/lib/lite_cable/server/client_socket/subscriptions.rb +3 -2
  31. data/lib/lite_cable/server/heart_beat.rb +4 -1
  32. data/lib/lite_cable/server/middleware.rb +7 -6
  33. data/lib/lite_cable/server/subscribers_map.rb +3 -0
  34. data/lib/lite_cable/version.rb +2 -1
  35. data/lib/litecable.rb +1 -0
  36. metadata +28 -75
  37. data/.gem_release.yml +0 -3
  38. data/.gitignore +0 -40
  39. data/.rubocop.yml +0 -63
  40. data/.travis.yml +0 -7
  41. data/Gemfile +0 -4
  42. data/Rakefile +0 -6
  43. data/bin/console +0 -14
  44. data/bin/setup +0 -8
  45. data/circle.yml +0 -8
  46. data/examples/sinatra/Gemfile +0 -16
  47. data/examples/sinatra/Procfile +0 -3
  48. data/examples/sinatra/README.md +0 -33
  49. data/examples/sinatra/anycable +0 -18
  50. data/examples/sinatra/app.rb +0 -52
  51. data/examples/sinatra/assets/app.css +0 -169
  52. data/examples/sinatra/assets/cable.js +0 -584
  53. data/examples/sinatra/assets/reset.css +0 -223
  54. data/examples/sinatra/bin/anycable-go +0 -0
  55. data/examples/sinatra/chat.rb +0 -39
  56. data/examples/sinatra/config.ru +0 -28
  57. data/examples/sinatra/views/index.slim +0 -8
  58. data/examples/sinatra/views/layout.slim +0 -15
  59. data/examples/sinatra/views/login.slim +0 -8
  60. data/examples/sinatra/views/resetcss.slim +0 -224
  61. data/examples/sinatra/views/room.slim +0 -68
  62. 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, '&lt;')
33
- .replace(/>/g, '&gt;')
34
- .replace(/"/g, '&quot;');
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