Sha256: 834e0da3486ee683223782bccd4566afcf37831c70e3d40f8b8a40bc8fd9d3f8

Contents?: true

Size: 919 Bytes

Versions: 4

Compression:

Stored size: 919 Bytes

Contents

$:.unshift "../lib"
require 'eventmachine'
require 'test/unit'

class TestConnectionCount < Test::Unit::TestCase
  def test_idle_connection_count
    EM.run {
      $count = EM.connection_count
      EM.stop_event_loop
    }

    assert_equal(0, $count)
  end

  module Client
    def connection_completed
      EM.next_tick{
        $client_connected = EM.connection_count
        EM.stop
      }
    end
  end

  module Server
    def post_init
      $server_connected = EM.connection_count
    end
  end

  def test_with_some_connections
    EM.run {
      $initial = EM.connection_count
      EM.start_server("127.0.0.1", 9999, Server)
      $server_started = EM.connection_count
      EM.next_tick{
        EM.connect("127.0.0.1", 9999, Client)
      }
    }

    assert_equal(0, $initial)
    assert_equal(1, $server_started)
    assert_equal(2, $server_connected)
    assert_equal(3, $client_connected)
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
eventmachine-eventmachine-0.12.8 tests/test_connection_count.rb
eventmachine-eventmachine-0.12.9 tests/test_connection_count.rb
eventmachine-0.12.8-java tests/test_connection_count.rb
eventmachine-0.12.8 tests/test_connection_count.rb