class Angelo::Minitest::WebsocketHelper
Constants
- WS_URL
Attributes
addr[W]
driver[R]
on_close[W]
on_message[W]
on_open[W]
path[W]
port[W]
socket[R]
Public Class Methods
new(addr, port, path)
click to toggle source
# File lib/angelo/minitest/helpers.rb, line 161 def initialize addr, port, path @addr, @port, @path = addr, port, path end
Public Instance Methods
go()
click to toggle source
# File lib/angelo/minitest/helpers.rb, line 196 def go @driver.start begin while msg = @socket.readpartial(4096) @driver.parse msg end rescue EOFError, SystemCallError => e end end
init()
click to toggle source
# File lib/angelo/minitest/helpers.rb, line 165 def init init_socket init_driver end
init_driver()
click to toggle source
# File lib/angelo/minitest/helpers.rb, line 176 def init_driver @driver = WebSocket::Driver.client self @driver.on :open do |e| @on_open.call(e) if Proc === @on_open end @driver.on :message do |e| @on_message.call(e) if Proc === @on_message end @driver.on :close do |e| @on_close.call(e) if Proc === @on_close end end
init_socket()
click to toggle source
# File lib/angelo/minitest/helpers.rb, line 170 def init_socket ip = @addr ip = Socket.getaddrinfo(@addr, 'http')[0][3] unless @addr =~ /\d+\.\d+\.\d+\.\d+/ @socket = Celluloid::IO::TCPSocket.new ip, @port end
url()
click to toggle source
# File lib/angelo/minitest/helpers.rb, line 192 def url WS_URL % [@addr, @port] + @path end