Sha256: a774a5f195cd9ad26160bd6d02e0a505524b4747b32cf0fb370f04e62d22999d
Contents?: true
Size: 757 Bytes
Versions: 7
Compression:
Stored size: 757 Bytes
Contents
#!/usr/bin/env ruby # frozen_string_literal: true $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 do |task| task.async do |subtask| while true subtask.sleep 10 puts "Connection count: #{@connections.size}" 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
7 entries across 7 versions & 1 rubygems