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.
9 10 11 12 13 |
# File 'lib/palapala/web_socket_client.rb', line 9 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.
7 8 9 |
# File 'lib/palapala/web_socket_client.rb', line 7 def url @url end |
Instance Method Details
#close ⇒ Object
23 24 25 |
# File 'lib/palapala/web_socket_client.rb', line 23 def close @socket.close end |
#read ⇒ Object
19 20 21 |
# File 'lib/palapala/web_socket_client.rb', line 19 def read @socket.readpartial(1024) end |
#write(data) ⇒ Object
15 16 17 |
# File 'lib/palapala/web_socket_client.rb', line 15 def write(data) @socket.write(data) end |