class Utopia::WebSocket::Client
This is a basic synchronous websocket client:
Attributes
driver[R]
url[R]
Public Class Methods
new(url, socket)
click to toggle source
# File lib/utopia/websocket/client.rb, line 31 def initialize(url, socket) @url = url @socket = socket @driver = ::WebSocket::Driver.client(self) @driver.start end
Public Instance Methods
read()
click to toggle source
# File lib/utopia/websocket/client.rb, line 44 def read while true data = @socket.readpartial(1024) @driver.parse(data) end rescue EOFError nil end
write(data)
click to toggle source
# File lib/utopia/websocket/client.rb, line 40 def write(data) @socket.write(data) end