action_channels 0.1.1 → 0.1.2

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: abc49cf79165358c0e9c7a33ffa290008db25120
4
- data.tar.gz: 8b04ebc3ca9d28b34adb03f6d1929cc6174935a9
3
+ metadata.gz: ec1b0643e485c608718ff7be71af50540fedd155
4
+ data.tar.gz: 24ae8e570afb08fd0df6163fa816acc034ccda40
5
5
  SHA512:
6
- metadata.gz: d8d168a249090a17d7da12df4c6c48bbf6c644fb0ddc9da87dc10924af91b692f6b4281b3f9bdc934401bcd583613dccbe0199ab2b47ed3f5d72e652931a7ab1
7
- data.tar.gz: 0131f3b388a7e0da7a1f118a523fc860471611ca551f99dc643f3570750f93e63a7090d226230d6286ecb14714ad379072f7dab454d93ea754a39ccdf3b9b12b
6
+ metadata.gz: 4e5867b4e9eea968ee6a9ae1d4a9f3b721eeabc8818652855bf753c85fa2f2dfbc2141bc4a51c090126b6c4179d3214471191c9a1a9b02bbfbe318eafd131150
7
+ data.tar.gz: 6341fe1ceee4897bb0328d6863c27332db32094a70bf64b6c56efd8850d705f0e6571bf34d3054709d436973c8e283070e01fdb4b1fcdf377af915be9324e389
data/.gitignore CHANGED
@@ -6,6 +6,8 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /examples/*.log
10
+ /examples/tmp/
9
11
 
10
12
  # rspec failure tracking
11
13
  .rspec_status
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
- f.match(%r{^(test|spec|features)/})
18
+ f.match(%r{^(test|spec|features|examples)/})
19
19
  end
20
20
  spec.bindir = "exe"
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
@@ -23,12 +23,16 @@ module ActionChannels
23
23
 
24
24
  def add_client(client)
25
25
  clients << client
26
+
26
27
  ActionChannels.logger.info "The channel ##{self.name} added a client"
28
+ ActionChannels.logger.debug "Count of client of channel ##{self.name} is #{self.clients.count}."
27
29
  end
28
30
 
29
31
  def remove_client(client)
30
32
  clients.delete client
33
+
31
34
  ActionChannels.logger.info "The channel ##{self.name} removed a client"
35
+ ActionChannels.logger.debug "Count of client of channel ##{self.name} is #{self.clients.count}."
32
36
  end
33
37
 
34
38
  def notify_all(message)
@@ -23,6 +23,8 @@ module ActionChannels
23
23
  def process_client(client)
24
24
  client.on :message, callback_on_message(client)
25
25
  client.on :close, callback_on_close(client)
26
+ client.on :error, callback_on_error(client)
27
+ client.on :io_error, callback_on_io_error(client)
26
28
 
27
29
  client
28
30
  end
@@ -47,6 +49,20 @@ module ActionChannels
47
49
  @message_sender ||= MessageSenders::WebSocket.new
48
50
  end
49
51
 
52
+ def callback_on_io_error(client)
53
+ proc do
54
+ ActionChannels.logger.error "Received io_error."
55
+ channel_repository.all.each { |channel| channel.remove_client(client) }
56
+ end
57
+ end
58
+
59
+ def callback_on_error(client)
60
+ lambda do |event|
61
+ ActionChannels.logger.error "Received error: #{event.message}"
62
+ channel_repository.all.each { |channel| channel.remove_client(client) }
63
+ end
64
+ end
65
+
50
66
  def callback_on_close(client)
51
67
  lambda do |event|
52
68
  ActionChannels.logger.info "Client closed connection."
@@ -1,3 +1,3 @@
1
1
  module ActionChannels
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_channels
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - German Antsiferov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-14 00:00:00.000000000 Z
11
+ date: 2018-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r-websocket