spec/support/fake_mqtt_server.rb
# Start the thread and open the socket that will process client connections
Start the thread and open the socket that will process client connections
Start the thread and open the socket that will process client connections
def start
    @socket ||= TCPServer.new(@address, 0)
    @address = @socket.addr[3]
    @port = @socket.addr[1]
    @thread ||= Thread.new do
      logger.info "Started a fake MQTT server on #{@address}:#{@port}"
      @times = 0
      loop do
        @times += 1
        client = @socket.accept
        @pings_received = 0
        handle_client(client)
        break if just_one
      end
    end
  end
def start @socket ||= TCPServer . new ( @address , 0 ) @address = @socket . addr [ 3 ] @port = @socket . addr [ 1 ] @thread ||= Thread . new do logger . info "Started a fake MQTT server on #{@address}:#{@port}" @times = 0 loop do @times += 1 client = @socket . accept @pings_received = 0 handle_client ( client ) break if just_one end end end
Start the thread and open the socket that will process client connections
Start the thread and open the socket that will process client connections
# Wait for a client to connect