Sha256: 361afe7508e9a16ade4086a755af6fde4d3ec96d17970d11bd7e90e9e47391d9

Contents?: true

Size: 675 Bytes

Versions: 18

Compression:

Stored size: 675 Bytes

Contents

require 'socket'

module ProconBypassMan::ProconDisplay
  class Server
    PORT = 9900

    def self.start!
      Thread.new do
        new.start_with_foreground
      end
    end

    def initialize
      @server = TCPServer.new('0.0.0.0', PORT)
    end

    def start_with_foreground
      loop do
        conn = @server.accept
        response = ServerApp.new(
          HttpRequest.parse(conn).to_hash
        ).call
        conn.write(response)
        conn.close
      end
    rescue Errno::EADDRINUSE => e
      ProconBypassMan::SendErrorCommand.execute(error: e)
    rescue => e
      ProconBypassMan::SendErrorCommand.execute(error: e)
      retry
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
procon_bypass_man-0.3.12 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.3.11 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.3.10 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.3.9 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.3.8.1 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.3.8 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.3.7 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.3.6 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.3.5 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.3.4 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.3.3.1 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.3.3 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.3.2 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.3.1 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.3.0 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.2.3 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.2.2 lib/procon_bypass_man/procon_display/server.rb
procon_bypass_man-0.2.1 lib/procon_bypass_man/procon_display/server.rb