crimson 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35177a021a41b1584fc359b754c07859c02ae15aa62c35444aed3d7a409dbf32
4
- data.tar.gz: 8225513ef25eff279c047f5b04ce1be7aa5e6978389dcdb4f0fe16f4f64bafb9
3
+ metadata.gz: 45d84a7e1fa187af8681fc1ae2c552306d1c1c851ce2580f7fa742b2f00e1f47
4
+ data.tar.gz: f67119be8bf2d896a0f7fff1d9190cb2d918933861b85d3d89c7bb16f97d8c00
5
5
  SHA512:
6
- metadata.gz: ece0df90c676a10a6c927adae1cd62efa52013876f34655613687f67bb74ca908a47fd7bd69f3a77bdce88a2744a122d603dbf705d8f0bc575a5e990c89480bd
7
- data.tar.gz: 748a7a5f94f2621f94f5811445d9003a7e306221ea3b8d7dbac7116dff943c988637de9dbd5c9ac6ac28532ef4ca0d71f85353a0f11e5e342589671913003946
6
+ metadata.gz: 89d12e4a422a7831dbc165b3661a09141ede52362bc89e3b5cb3d700ac637bf24d7f2ade2ec4c6e5d465bc5e58c5c2476d6fc799d4da00ec49994a46624931e8
7
+ data.tar.gz: faa0b07ae8145d58fd07c130b3df89a8f75fee37457960a6a088f4c706a440cf08a459375d09415942f72ce822241080244929560dd838f7fe0029b2eb06c3b1
@@ -27,8 +27,10 @@ module Crimson
27
27
  end
28
28
 
29
29
  def write(message = {})
30
- connection.write(message)
31
- connection.flush
30
+ unless connection.closed?
31
+ connection.write(message)
32
+ connection.flush
33
+ end
32
34
  end
33
35
 
34
36
  def on_commit(object, changes)
@@ -38,24 +38,21 @@ module Crimson
38
38
 
39
39
  def call_async(env)
40
40
  Async::WebSocket::Adapters::Rack.open(env, protocols: ['ws']) do |connection|
41
- id = :"client_#{Utilities.generate_id}"
42
- client = Client.new(id, connection)
43
- clients[connection] = client
44
-
45
- @on_connect&.call(client)
41
+ id = :"client_#{Utilities.generate_id}"
42
+ client = Client.new(id, connection)
43
+ clients[connection] = client
44
+
45
+ @on_connect&.call(client)
46
46
 
47
47
  begin
48
48
  while message = connection.read
49
49
  client.on_message(message)
50
50
  end
51
51
  rescue Protocol::WebSocket::ClosedError
52
-
52
+ ensure
53
+ @on_disconnect&.call(client)
54
+ clients.delete(connection)
53
55
  end
54
-
55
- connection.close
56
- ensure
57
- @on_disconnect&.call(client)
58
- clients.delete(connection)
59
56
  end
60
57
  end
61
58
 
@@ -1,3 +1,3 @@
1
1
  module Crimson
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crimson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rizwan Qureshi