Class: Palapala::WebSocketClient
- Inherits:
-
Object
- Object
- Palapala::WebSocketClient
- Defined in:
- lib/palapala/web_socket_client.rb
Overview
Create a socket wrapper that conforms to what the websocket-driver expects
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(url) ⇒ WebSocketClient
constructor
A new instance of WebSocketClient.
- #read ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize(url) ⇒ WebSocketClient
Returns a new instance of WebSocketClient.
11 12 13 14 15 |
# File 'lib/palapala/web_socket_client.rb', line 11 def initialize(url) @url = url uri = URI.parse(url) @socket = TCPSocket.new(uri.host, uri.port) end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/palapala/web_socket_client.rb', line 9 def url @url end |
Instance Method Details
#close ⇒ Object
25 26 27 |
# File 'lib/palapala/web_socket_client.rb', line 25 def close @socket.close end |
#read ⇒ Object
21 22 23 |
# File 'lib/palapala/web_socket_client.rb', line 21 def read @socket.readpartial(1024) end |
#write(data) ⇒ Object
17 18 19 |
# File 'lib/palapala/web_socket_client.rb', line 17 def write(data) @socket.write(data) end |