Method: Discordrb::Gateway#inject_reconnect
- Defined in:
- lib/discordrb/gateway.rb
#inject_reconnect(url = nil) ⇒ Object
Injects a reconnect event (op 7) into the event processor, causing Discord to reconnect to the given gateway URL. If the URL is set to nil, it will reconnect and get an entirely new gateway URL. This method has not much use outside of testing and implementing highly custom reconnect logic.
225 226 227 228 229 230 231 232 233 |
# File 'lib/discordrb/gateway.rb', line 225 def inject_reconnect(url = nil) # When no URL is specified, the data should be nil, as is the case with Discord-sent packets. data = url ? { url: url } : nil ({ op: Opcodes::RECONNECT, d: data }.to_json) end |