Sha256: 391c0868fc146037d0d42749a295c952fc73681ac5e7a7dd0d3df07113a7823e

Contents?: true

Size: 741 Bytes

Versions: 5

Compression:

Stored size: 741 Bytes

Contents

#!/usr/bin/env ruby

$LOAD_PATH << File.expand_path("../../lib", __dir__)

require 'set'

require 'async/reactor'
require 'async/io/host_endpoint'
require 'async/io/protocol/line'

class Server
	def initialize
		@connections = []
	end
	
	def run(endpoint)
		Async::Reactor.run do |task|
			task.async do |subtask|
				while true
					subtask.sleep 10
					puts "Connection count: #{@connections.count}"
				end
			end
				
			
			endpoint.accept do |peer|
				stream = Async::IO::Stream.new(peer)
				
				@connections << stream
			end
		end
	end
end

Async.logger.level = Logger::INFO
Async.logger.info("Starting server...")
server = Server.new

endpoint = Async::IO::Endpoint.parse(ARGV.pop || "tcp://localhost:7234")
server.run(endpoint)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
async-io-1.18.2 examples/millions/server.rb
async-io-1.18.1 examples/millions/server.rb
async-io-1.17.2 examples/millions/server.rb
async-io-1.17.1 examples/millions/server.rb
async-io-1.16.4 examples/millions/server.rb