Class: Farcall::DebugSocketStream

Inherits:
SocketStream show all
Defined in:
lib/farcall/json_transport.rb

Overview

The socket stream that imitates slow data reception over the slow internet connection use to for testing only

Instance Method Summary collapse

Methods inherited from SocketStream

#<<, #eof?, #read

Constructor Details

#initialize(socket, timeout) ⇒ DebugSocketStream

Returns a new instance of DebugSocketStream.

Parameters:

  • timeout (float)

    between sending individual bytes in seconds



41
42
43
44
# File 'lib/farcall/json_transport.rb', line 41

def initialize socket, timeout
  super socket
  @timeout = timeout
end

Instance Method Details

#write(data) ⇒ Object



46
47
48
49
50
51
# File 'lib/farcall/json_transport.rb', line 46

def write data
  data.to_s.each_char { |x|
    super x
    sleep @timeout
  }
end