vendor/gems/gems/firewatir-1.2.1/container.rb
#
# Description:
#  Reads the javascript execution result from the jssh socket. 
#
# Input:
# 	- socket - It is the jssh socket, the  only point of communication between the browser and firewatir scripts.
# 
# Output:	
#	The javascript execution result as string.	
#

Reads the javascript execution result from the jssh socket.

It is the jssh socket, the  only point of communication between the browser and firewatir scripts.

The javascript execution result as string.
Reads the javascript execution result from the jssh socket . It is the jssh socket the only point of communication between the browser and firewatir scripts . The javascript execution result as string .
def read_socket(socket = jssh_socket)
        return_value = "" 
        data = ""
        receive = true
        s = nil
        while(s == nil) do
            s = Kernel.select([socket] , nil , nil, 1)
        end
        for stream in s[0]
            data = stream.recv(1024)
            while(receive)
                return_value += data
                if(return_value.include?("\n> "))
                    receive = false
                else    
                    data = stream.recv(1024)
                end    
            end
        end
        length = return_value.length 
        if length <= 3 
            return_value = ""
        elsif(return_value[0..2] == "\n> ")    
            return_value = return_value[3..length-1]
        else    
            return_value = return_value[0..length-4]
        end 
        if(return_value[return_value.length - 3..return_value.length - 1] == "\n> ")
            return_value = return_value[0..return_value.length - 4]
        end    
        if(return_value[0..2] == "\n> ")
            return_value = return_value[3..return_value.length - 1]
        end   
        return return_value
    end
def read_socket ( socket = jssh_socket ) return_value = "" data = "" receive = true s = nil while ( s == nil ) do s = Kernel . select ( [ socket ] , nil , nil , 1 ) end for stream in s [ 0 ] data = stream . recv ( 1024 ) while ( receive ) return_value += data if ( return_value . include? ( "\n> " ) ) receive = false else data = stream . recv ( 1024 ) end end end length = return_value . length if length <= 3 return_value = "" elsif ( return_value [ 0 .. 2 ] == "\n> " ) return_value = return_value [ 3 .. length - 1 ] else return_value = return_value [ 0 .. length - 4 ] end if ( return_value [ return_value . length - 3 .. return_value . length - 1 ] == "\n> " ) return_value = return_value [ 0 .. return_value . length - 4 ] end if ( return_value [ 0 .. 2 ] == "\n> " ) return_value = return_value [ 3 .. return_value . length - 1 ] end return return_value end
Description:
Reads the javascript execution result from the jssh socket.
Description : Reads the javascript execution result from the jssh socket .
#puts Thread.list
 #if(s != nil)
 #puts "data is : #{data}"
 #while(data.length == 1024)
 #puts "return_value is : #{return_value}"
 #puts "data length is : #{data.length}"
 # If received data is less than 1024 characters or for last data 
 # we read in the above loop 
 #return_value += data
 # Get the command prompt inserted by JSSH
 #s = Kernel.select([socket] , nil , nil, 0.3)
 #if(s != nil)
 #    for stream in s[0]
 #        return_value += socket.recv(1024)
 #    end
 #end
 #puts "Return value before removing command prompt is : #{return_value}"
 #Remove the command prompt. Every result returned by JSSH has "\n> " at the end.
 #return_value = return_value[0..length-3]
 #puts "Return value after removing command prompt is : #{return_value}"
 #socket.flush
 # make sure that command prompt doesn't get there.
 #puts "return value is : #{return_value}"

socket
<not_specific>
jssh_socket
<not_specific>