rxio 0.13.3 → 0.13.4

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: 18ba608c0a8d8d19e8040f77ae85cbc5c2fd0b6d
4
- data.tar.gz: 70abef8d3afde6333809944d1e4d0492588c5fb8
3
+ metadata.gz: 62f06a50cce6b403b28c09502aba950ec863fd16
4
+ data.tar.gz: a7b84641ff2cde46908d8afc3e4c09d03f6e8c47
5
5
  SHA512:
6
- metadata.gz: 9a17f7c14d369036c8824acaf8b07106e64795b7e1a132337f833bf56b094965356e46193ffc9916228695f5e6b0c4d76453c5d3380e9636a22f4e03a10e7d74
7
- data.tar.gz: 1c57bcd0d701215adbb8ba75096fa9971c0fc4850d7f2800adffadc273394b6c90b452799aab2a80d50383b9b8d29c28cc9a9f7720ae8fa7304f771ee869e148
6
+ metadata.gz: 673842e6d6b54ba630e1bc0f9c6170c7aec543bf98ac171cf55821c22339a69ada60062b2c9dbbfa4a7486e31fb25ebd88eeed03e80e91bc3cd0a08832838d56
7
+ data.tar.gz: f661465b2dc21407b63c38068441d1e6148c064b4d15d5233488eb147d832b409e681e03d9b69ea772b17aecb6881432bea957670ee61c6530ba88d66b589c88
data/README.md CHANGED
@@ -309,6 +309,20 @@ es.shutdown
309
309
  puts 'Client has terminated!'
310
310
  ```
311
311
 
312
+ ### Dealing with Client Errors
313
+
314
+ Whenever an error occurs as the result of handling a client's message should can be logged through the *client_error* method in *RxIO::Service*.
315
+ The default implementation of this method simply spits out the error on STDOUT and drops the client.
316
+ It can be overloaded to provide custom functionality upon client errors.
317
+
318
+ ```ruby
319
+ # Default implementation for 'client_error'
320
+ def client_error c, e
321
+ puts "[!] ERROR [#{c[:peer][:addr]}:#{c[:peer][:name]}] - #{e}"
322
+ c[:sock].close rescue nil
323
+ end
324
+ ```
325
+
312
326
  ## License
313
327
 
314
328
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/lib/rxio/client.rb CHANGED
@@ -29,9 +29,9 @@ module RxIO
29
29
 
30
30
  # Construct
31
31
  # Builds a *Client* around a given _service_handler_ module, set to connect to _addr_ on _port_.
32
- # @param [String] addr
33
- # @param [Fixnum] port
34
- # @param [Module] service_handler
32
+ # @param [String] addr Address to which the client should connect
33
+ # @param [Fixnum] port Port on which the client should connect
34
+ # @param [Module] service_handler Module implementing service client logic
35
35
  def initialize addr, port, service_handler
36
36
 
37
37
  # Set Address & Port
data/lib/rxio/service.rb CHANGED
@@ -26,9 +26,9 @@ module RxIO
26
26
 
27
27
  # Construct
28
28
  # Builds a *Service* around a given _service_handler_ module, set to listen for incoming connections @ _addr_ on _port_.
29
- # @param [String] addr
30
- # @param [Fixnum] port
31
- # @param [Module] service_handler
29
+ # @param [String] addr Address on which the service should listen
30
+ # @param [Fixnum] port Port on which the service should listen
31
+ # @param [Module] service_handler Module implementing the service logic
32
32
  def initialize addr, port, service_handler
33
33
 
34
34
  # Set Address & Port
@@ -107,7 +107,7 @@ module RxIO
107
107
  # Register Client
108
108
  # Creates a new Client around a given socket _s_ and registers it.
109
109
  # Also, notifies the Handler Module if the _on_join_ method is available.
110
- # @param [TCPSocket] s
110
+ # @param [TCPSocket] s The new client's network socket
111
111
  def add_client s
112
112
 
113
113
  # Register Socket
@@ -148,7 +148,7 @@ module RxIO
148
148
  # Accept Socket
149
149
  # Tries to accept any queued connection request in a non-blocking manner.
150
150
  # Registers a new Client through _add_client_ around the newly-accepted socket if present.
151
- # @param [TCPServer] s
151
+ # @param [TCPServer] s The service's listening socket
152
152
  def acpt_sock s
153
153
 
154
154
  # Accept
@@ -160,7 +160,7 @@ module RxIO
160
160
 
161
161
  # Get Endpoint for Socket - Callback for IOBase
162
162
  # Finds the Client associated with a given Socket
163
- # @param [TCPSocket] s
163
+ # @param [TCPSocket] s Any socket
164
164
  # @return [Hash] The Endpoint associated with Socket _s_, or nil
165
165
  def get_endpoint_for_sock s
166
166
  @cmap[s]
@@ -168,7 +168,7 @@ module RxIO
168
168
 
169
169
  # On Drop - Callback for IOBase
170
170
  # Unregisters a Client and closes the associated socket.
171
- # @param [Hash] c
171
+ # @param [Hash] c Client Hash
172
172
  def on_drop c
173
173
 
174
174
  # Drop Client
@@ -179,5 +179,14 @@ module RxIO
179
179
  # Kill Socket
180
180
  c[:sock].close rescue nil
181
181
  end
182
+
183
+ # Client Error
184
+ # Handles an Error from a Client
185
+ # @param [Hash] c Client Hash
186
+ # @param [String] e Error String
187
+ def client_error c, e
188
+ puts "[!] ERROR [#{c[:peer][:addr]}:#{c[:peer][:name]}] - #{e}"
189
+ c[:sock].close rescue nil
190
+ end
182
191
  end
183
192
  end
data/lib/rxio/version.rb CHANGED
@@ -5,5 +5,5 @@
5
5
  module RxIO
6
6
 
7
7
  # Version
8
- VERSION = '0.13.3'
8
+ VERSION = '0.13.4'
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rxio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.3
4
+ version: 0.13.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eresse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-24 00:00:00.000000000 Z
11
+ date: 2017-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler