iodine 0.1.14 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of iodine might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1fd668ed3460e3102fbd0ba91c8be5d89100356
4
- data.tar.gz: 59416be95eb95921a05f9fa520aa8d61e843388f
3
+ metadata.gz: 688611fe0ab9da4acb64bac423d6f72899e981a0
4
+ data.tar.gz: afa9582b3fde67b3ea77aa7389d078cc00c762ba
5
5
  SHA512:
6
- metadata.gz: 89add89d23f96c6870250a0028dc5298051147233c11d561f970f68b262e548e62454e92f6a78869c9938b46760cc5f4b146070b397e9ed593e5b1ba7704aa3e
7
- data.tar.gz: 38db9c8b52f4ecf1083c1509f12a7aaa302bdfce668dbb592c09fea19a55a8c08d3d44439e559b116b2a879dedfdeb7ad7dbe56ae880c82dec1844aba90d1a70
6
+ metadata.gz: acf6eb30f924bb79ed5026bfef62e4ee30ca09dd07b93a33fc4db8be8237da6f273ac8f9208622099a5c55c3a94894826e65baebdca4c8b87009254206ed4e1a
7
+ data.tar.gz: 2d9ab314382fe82fa514cc5f38def28d79e39ff5e5c8e66277e972347a788481129f556aafa81bbf54ad0a3410664814844c91cc71876fe41b914e57d1fc3a08
@@ -8,9 +8,15 @@ Please notice that this change log contains changes for upcoming releases as wel
8
8
 
9
9
  ***
10
10
 
11
- Change log v.0.1.14
11
+ Change log v.0.1.15
12
+
13
+ **Update**: IO reactor will now update IO status even when tasks are pending. IO will still be read only when there are no more tasks to handle, but this allows chained tasks to relate to the updated IO status. i.e. this should improve websocket availability for broadcasting (delay from connection to availability might occure until IO is registered).
14
+
15
+ **Update**: Websockets now support the `on_ping` callback, which will be called whenever a ping was sent without error.
12
16
 
13
- **
17
+ ***
18
+
19
+ Change log v.0.1.14
14
20
 
15
21
  **Update**: the Response now supports `redirect_to` for both permanent and temporary redirection, with an optional `flash` cookie setup.
16
22
 
@@ -52,20 +52,20 @@ module Iodine
52
52
  @status_loop = Proc.new {|io| @io_out << io if io.closed? || !(io.stat.readable? rescue false) }
53
53
  @close_callback = Proc.new {|prot| prot.on_close if prot }
54
54
  @reactor = [ (Proc.new do
55
+ @ios.keys.each(&@status_loop)
56
+ @ios.values.each(&@timeout_proc)
57
+ until @io_in.empty?
58
+ n_io = @io_in.pop
59
+ @ios[n_io[0]] = n_io[1]
60
+ end
61
+ until @io_out.empty?
62
+ o_io = @io_out.pop
63
+ o_io.close unless o_io.closed?
64
+ run @ios.delete(o_io), &@close_callback
65
+ end
55
66
  if @queue.empty?
56
67
  #clear any closed IO objects.
57
68
  @time = Time.now
58
- @ios.keys.each(&@status_loop)
59
- @ios.values.each(&@timeout_proc)
60
- until @io_in.empty?
61
- n_io = @io_in.pop
62
- @ios[n_io[0]] = n_io[1]
63
- end
64
- until @io_out.empty?
65
- o_io = @io_out.pop
66
- o_io.close unless o_io.closed?
67
- run @ios.delete(o_io), &@close_callback
68
- end
69
69
  # react to IO events
70
70
  begin
71
71
  r = IO.select(@ios.keys, nil, nil, 0.15)
@@ -28,6 +28,9 @@ module Iodine
28
28
  # cleanup, if needed, using this callback.
29
29
  def on_close
30
30
  end
31
+ # called whenever a ping is sent (no data transfer caused timeout).
32
+ def on_ping
33
+ end
31
34
  # extra cleanup, if needed, when server is shutting down while the websocket is connected.
32
35
  #
33
36
  # You can use on_close unless some "going away" cleanup is required.
@@ -48,15 +51,17 @@ module Iodine
48
51
 
49
52
  # Write data to the client, using Websockets encoded frames.
50
53
  def write data
51
- # We leverage the fact that the Http response can be used to send Websocket data.
52
- #
53
- # you can also use Websocket#send_data or it's alias Websocket#<< for example:
54
+ # We can use Websocket#send_data or it's alias Websocket#<< for example:
54
55
  #
55
56
  # # @request[:io] contains the Websockets Protocol instance
56
57
  # @request[:io] << data
57
58
  #
58
59
  # do NOT use Websocket#write (which writes the data directly, bypassing the protocol).
59
- @response << data
60
+ #
61
+ # We can also leverage the fact that the Http response can be used to send Websocket data.
62
+ #
63
+ # @response << data
64
+ (@___ws_io ||= @request[:io]) << data
60
65
  end
61
66
 
62
67
  # Send messages directly to a specific Websocket.
@@ -71,7 +76,7 @@ module Iodine
71
76
  # This implementation is limited to a single process on a single server.
72
77
  # Consider using Redis for a scalable implementation.
73
78
  def broadcast data
74
- ::Iodine::Http::Websockets.broadcast data, self
79
+ ::Iodine::Http::Websockets.broadcast data, @request[:io]
75
80
  end
76
81
  # Closes the connection
77
82
  def close
@@ -81,9 +81,9 @@ module Iodine
81
81
  end
82
82
  alias :<< :send_data
83
83
 
84
- # Sends a ping.
84
+ # Sends a ping and calles the :on_ping callback (if exists).
85
85
  def ping
86
- write PING_FRAME
86
+ write(PING_FRAME) && ( (@handler.respond_to?(:on_ping) && @handler.on_ping) || true)
87
87
  end
88
88
  # Sends an empty pong.
89
89
  def pong
@@ -1,3 +1,3 @@
1
1
  module Iodine
2
- VERSION = "0.1.14"
2
+ VERSION = "0.1.15"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iodine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boaz Segev