Sha256: 8092efca9bdd4ee5a2b7d89a3dd2532ad0aef95532998ab9021fa3b144f5aa88

Contents?: true

Size: 529 Bytes

Versions: 4

Compression:

Stored size: 529 Bytes

Contents

module Capybara::Poltergeist
  class Server
    attr_reader :port, :socket, :timeout

    def initialize(port, timeout = nil)
      @port    = port
      @timeout = timeout
      start
    end

    def timeout=(sec)
      @timeout = @socket.timeout = sec
    end

    def start
      @socket = WebSocketServer.new(port, timeout)
    end

    def stop
      @socket.close
    end

    def restart
      stop
      start
    end

    def send(message)
      @socket.send(message) or raise DeadClient.new(message)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
poltergeist-1.0.3 lib/capybara/poltergeist/server.rb
poltergeist-1.0.2 lib/capybara/poltergeist/server.rb
poltergeist-1.0.1 lib/capybara/poltergeist/server.rb
poltergeist-1.0.0 lib/capybara/poltergeist/server.rb