litecable 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4640e78d6f9a77cf9257cb0774ff249ec1b5f699
4
- data.tar.gz: a2cc894fc9e355baa79d82afde6682c570ddc21c
3
+ metadata.gz: a4cd86a9f6cb1636c77ec87485b61050eaffade5
4
+ data.tar.gz: d602270a3b4e9f8e57744a226219743a6e71c510
5
5
  SHA512:
6
- metadata.gz: '0588bb0b62119753f79382bfe9955f7db54a693f2625c05426bcf08f131ed8b5b10fdb1e2bd0950545e030530ecfa823383c037747e654b43e7aa650db7187cb'
7
- data.tar.gz: 6365980a8eece62d0d092349ed583afb1a04e749577f994da5da004dfe4576b64c07edc8744680eecda8f9637d726e6c878a0d50cd281c322070adb67c36df37
6
+ metadata.gz: 5959fb92c1c91a96f94f06c94af4a6ee27f6958c9b4690a4bb28091a37c5ba464534e5d5f1480c7d80e68694fbf112db3f6803d5a514ad867b98cbccbc1ba779
7
+ data.tar.gz: 7d5aec25eaf3fadc7a210b10bcd1d6797e0329d58dcf80ee1dbf552d85aa8a4f2c01be8b3699b4cc3e4252c2bf77915b847936169cf13401695667192916488c
@@ -1,6 +1,10 @@
1
1
  # Change log
2
2
 
3
- ## master
3
+ ## 0.4.1 (2017-02-04)
4
+
5
+ - Use `websocket-ruby` with subprotocols support ([@palkan][])
6
+
7
+ ## 0.4.0 (2017-01-29)
4
8
 
5
9
  - Initial version. ([@palkan][])
6
10
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Gem Version](https://badge.fury.io/rb/litecable.svg)](https://rubygems.org/gems/litecable) [![Build Status](https://travis-ci.org/anycable/litecable.svg?branch=master)](https://travis-ci.org/anycable/litecable) [![Circle CI](https://circleci.com/gh/anycable/litecable/tree/master.svg?style=svg)](https://circleci.com/gh/anycable/anycable/tree/master)
1
+ [![Gem Version](https://badge.fury.io/rb/litecable.svg)](https://rubygems.org/gems/litecable) [![Build Status](https://travis-ci.org/palkan/litecable.svg?branch=master)](https://travis-ci.org/palkan/litecable) [![Circle CI](https://circleci.com/gh/palkan/litecable/tree/master.svg?style=svg)](https://circleci.com/gh/palkan/litecable/tree/master)
2
2
 
3
3
  # Lite Cable
4
4
 
@@ -9,8 +9,8 @@ gem 'puma'
9
9
  gem 'pry-byebug'
10
10
 
11
11
  # litecable deps
12
- gem "anyway_config", "~>0.5.0"
13
- gem "websocket"
12
+ gem "anyway_config", "~> 0.5.0"
13
+ gem "websocket", "~> 1.2.4"
14
14
 
15
15
  # anycable
16
16
  gem "anycable", "~> 0.4.2"
@@ -7,7 +7,7 @@ module Chat
7
7
  identified_by :user, :sid
8
8
 
9
9
  def connect
10
- @user = cookies["user"]
10
+ @user = cookies["user"] || 'John'
11
11
  @sid = request.params["sid"]
12
12
  reject_unauthorized_connection unless @user
13
13
  $stdout.puts "#{@user} connected"
@@ -11,7 +11,7 @@ h2 ="Room: #{@room_id}"
11
11
  span Send!
12
12
 
13
13
  javascript:
14
- var roomId = #{{ @room_id }};
14
+ var roomId = "#{{ @room_id }}";
15
15
  var user = "#{{ @user }}";
16
16
  var socketId = Date.now();
17
17
 
@@ -56,7 +56,7 @@ module LiteCable
56
56
  when "unsubscribe" then remove(data["identifier"])
57
57
  when "message" then perform_action(data["identifier"], data["data"])
58
58
  else
59
- raise UnknownCommandError
59
+ raise UnknownCommandError, "Command not found #{command}"
60
60
  end
61
61
  end
62
62
 
@@ -113,6 +113,8 @@ module LiteCable
113
113
  frame = WebSocket::Frame::Outgoing::Server.new(version: version, type: :close, code: 1000)
114
114
  @socket.write(frame.to_s) if frame.supported?
115
115
  @socket.close
116
+ rescue IOError, Errno::EPIPE, Errno::ETIMEDOUT # rubocop:disable Lint/HandleExceptions
117
+ # already closed
116
118
  end
117
119
 
118
120
  def keepalive
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module LiteCable
3
3
  module Server
4
- require "lite_cable/server/websocket_ext/protocols"
5
4
  # Rack middleware to hijack the socket
6
5
  class Middleware
7
6
  class HijackNotAvailable < RuntimeError; end
@@ -30,10 +29,11 @@ module LiteCable
30
29
  private
31
30
 
32
31
  def send_handshake(env)
33
- handshake = WebSocket::Handshake::Server.new
34
- handshake.from_rack env
35
- handshake.protocols LiteCable::INTERNAL[:protocols]
32
+ handshake = WebSocket::Handshake::Server.new(
33
+ protocols: LiteCable::INTERNAL[:protocols]
34
+ )
36
35
 
36
+ handshake.from_rack env
37
37
  env['rack.hijack_io'].write handshake.to_s
38
38
  handshake
39
39
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module LiteCable
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1"
4
4
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.add_dependency "anyway_config", "~>0.5.0"
21
21
 
22
22
  spec.add_development_dependency "rack", "~> 2.0"
23
- spec.add_development_dependency "websocket", "~> 1.2.0"
23
+ spec.add_development_dependency "websocket", "~> 1.2.4"
24
24
  spec.add_development_dependency "websocket-client-simple", "~> 0.3.0"
25
25
  spec.add_development_dependency "concurrent-ruby", "~> 1.0.0"
26
26
  spec.add_development_dependency "puma", "~> 3.6.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: litecable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-29 00:00:00.000000000 Z
11
+ date: 2017-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anyway_config
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.2.0
47
+ version: 1.2.4
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.2.0
54
+ version: 1.2.4
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: websocket-client-simple
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -225,7 +225,6 @@ files:
225
225
  - lib/lite_cable/server/heart_beat.rb
226
226
  - lib/lite_cable/server/middleware.rb
227
227
  - lib/lite_cable/server/subscribers_map.rb
228
- - lib/lite_cable/server/websocket_ext/protocols.rb
229
228
  - lib/lite_cable/version.rb
230
229
  - lib/litecable.rb
231
230
  - litecable.gemspec
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
- # Add missing protocols support to websocket-ruby
3
- module WebSocketExt
4
- module Protocols # :nodoc:
5
- module Handshake # :nodoc:
6
- # Specify server protocols
7
- def protocols(values)
8
- @protocols = values
9
- end
10
-
11
- # Return matching protocol
12
- def protocol
13
- return @protocol if instance_variable_defined?(:@protocol)
14
- protos = @headers['sec-websocket-protocol']
15
-
16
- return @protocol = nil unless protos
17
- @protocol = begin
18
- protos = protos.split(/ *, */) if protos.is_a?(String)
19
- protos.find { |p| @protocols.include?(p) }
20
- end
21
- end
22
- end
23
-
24
- module Handler # :nodoc:
25
- def handshake_keys
26
- return super unless @handshake.protocol
27
- super + [
28
- [
29
- 'Sec-WebSocket-Protocol',
30
- @handshake.protocol
31
- ]
32
- ]
33
- end
34
- end
35
- end
36
- end
37
-
38
- WebSocket::Handshake::Server.include WebSocketExt::Protocols::Handshake
39
- [
40
- WebSocket::Handshake::Handler::Server04,
41
- WebSocket::Handshake::Handler::Server75,
42
- WebSocket::Handshake::Handler::Server76
43
- ].each do |handler|
44
- handler.prepend WebSocketExt::Protocols::Handler
45
- end