Class: Breakout::Socket
Instance Attribute Summary
Attributes inherited from WebSocket
#header, #path, #server
Instance Method Summary
collapse
Methods inherited from WebSocket
#close_socket, #handshake, #host, #location, #origin, #tcp_socket
Constructor Details
#initialize(url) ⇒ Socket
Returns a new instance of Socket.
3
4
5
6
|
# File 'lib/breakout/socket.rb', line 3
def initialize(url)
@ws = WebSocket.new(url)
end
|
Instance Method Details
#close ⇒ Object
8
9
10
|
# File 'lib/breakout/socket.rb', line 8
def close
@ws.close
end
|
#receive ⇒ Object
12
13
14
|
# File 'lib/breakout/socket.rb', line 12
def receive
@ws.receive
end
|
#send(msg) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/breakout/socket.rb', line 16
def send(msg)
if msg.is_a?(String)
@ws.send(msg)
else
@ws.send(msg.to_json)
end
end
|