foxbat 0.2.3 → 0.2.4

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.
data/lib/em/connection.rb CHANGED
@@ -43,5 +43,9 @@ module EventMachine
43
43
  @netty_handler.peername
44
44
  end
45
45
 
46
+ def comm_inactivity_timeout=(seconds)
47
+ # todo
48
+ end
49
+
46
50
  end
47
51
  end
data/lib/eventmachine.rb CHANGED
@@ -18,6 +18,7 @@ module EventMachine
18
18
  def self.kqueue; end
19
19
 
20
20
  def self.run(blk=nil, tail=nil, &block)
21
+ @alive = true
21
22
  @@threadpool = Executors.newCachedThreadPool
22
23
 
23
24
  block.call
@@ -27,12 +28,16 @@ module EventMachine
27
28
 
28
29
  def self.stop
29
30
  @@servers.each { |s| s.stop }
30
- @@threadpool.shutdownNow
31
+ @@threadpool.shutdown
31
32
  end
32
33
 
33
34
  def self.executor
34
35
  @@threadpool
35
36
  end
36
37
 
38
+ def self.reactor_running?
39
+ @alive
40
+ end
41
+
37
42
  end
38
43
 
@@ -6,8 +6,9 @@ module Foxbat
6
6
 
7
7
  class NettyConnection < SimpleChannelUpstreamHandler
8
8
 
9
- def initialize(connection)
9
+ def initialize(connection, group)
10
10
  @connection = connection
11
+ @group = group
11
12
  connection.netty_handler = self
12
13
  super()
13
14
  end
@@ -23,6 +24,10 @@ module Foxbat
23
24
  end
24
25
 
25
26
  private
27
+
28
+ def channelOpen(ctx, e)
29
+ @group.add(e.getChannel)
30
+ end
26
31
 
27
32
  def channelConnected(ctx, e)
28
33
  @pipeline = ctx.getPipeline
@@ -10,9 +10,10 @@ module Foxbat
10
10
  class Pipeline
11
11
  include ChannelPipelineFactory
12
12
 
13
- def initialize(handler, options={}, ssl_context=nil, &block)
13
+ def initialize(handler, group, options={}, ssl_context=nil, &block)
14
14
  @options = options
15
15
  @handler = handler
16
+ @group = group
16
17
  @block = block
17
18
  @context = ssl_context
18
19
  end
@@ -25,11 +26,14 @@ module Foxbat
25
26
  end
26
27
  h = @handler.new(@options)
27
28
  @block.call(h) if @block
28
- connection = NettyConnection.new(h)
29
+ connection = NettyConnection.new(h, @group)
29
30
  pipeline.addLast("handler", connection)
30
31
  pipeline
31
32
  end
32
-
33
+
34
+ def releaseExternalResources
35
+ p 'cleaning up factory...'
36
+ end
33
37
  end
34
38
 
35
39
  end
data/lib/foxbat/server.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  import java.net.InetSocketAddress
2
+ import org.jboss.netty.channel.group.DefaultChannelGroup
2
3
  import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory
3
4
  import org.jboss.netty.bootstrap.ServerBootstrap
4
5
  require_relative 'pipeline'
@@ -12,20 +13,22 @@ module Foxbat
12
13
  if options[:secure]
13
14
  @context = Security.setup_ssl_context(options[:keystore])
14
15
  end
15
-
16
+
17
+ @group = DefaultChannelGroup.new
16
18
  @address = InetSocketAddress.new(host, port)
17
- @pipeline = Pipeline.new(klass, options, @context, &block)
19
+ @pipeline = Pipeline.new(klass, @group, options, @context, &block)
18
20
  end
19
21
 
20
22
  def start(threadpool)
21
23
  @factory = NioServerSocketChannelFactory.new(threadpool, threadpool)
22
24
  @bootstrap = ServerBootstrap.new(@factory)
23
25
  @bootstrap.setPipelineFactory(@pipeline)
24
- @bootstrap.bind(@address)
26
+ @server_channel = @bootstrap.bind(@address)
27
+ @group.add(@server_channel)
25
28
  end
26
29
 
27
30
  def stop
28
- @bootstrap.releaseExternalResources
31
+ @group.close.awaitUninterruptibly
29
32
  end
30
33
  end
31
34
 
@@ -1,3 +1,3 @@
1
1
  module Foxbat
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foxbat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: