Class: Cybertrain::WebSocket::Connection

Inherits:
Object
  • Object
show all
Defined in:
cybertrain/websocket.rb

Overview

What a callback uses to talk back on the connection it was called for. Valid only during the call.

Instance Method Summary collapse

Instance Method Details

#close ⇒ nil

Closes the connection (close 1000); the feed reconnects after the retry delay.

Returns:

  • (nil)


84
85
86
# File 'cybertrain/websocket.rb', line 84

def close
  @client.close
end

#last_opcode ⇒ Symbol

The kind of the message on_message was last given.

Returns:

  • (Symbol) —

    :text or :binary



91
92
93
# File 'cybertrain/websocket.rb', line 91

def last_opcode
  @last_opcode
end

#send_binary(data) ⇒ nil

Sends a binary message.

Parameters:

  • data (String)

Returns:

  • (nil)


76
77
78
# File 'cybertrain/websocket.rb', line 76

def send_binary(data)
  @client.send_binary(data)
end

#send_text(text) ⇒ nil

Sends a text message.

Parameters:

  • text (String)

Returns:

  • (nil)

Raises:

  • (Error) —

    when the connection is gone (the feed reconnects)



68
69
70
# File 'cybertrain/websocket.rb', line 68

def send_text(text)
  @client.send_text(text)
end