Class: WebhookDump::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/webhook_dump.rb

Constant Summary collapse

WEBSOCKET_URL =
'wss://webhookdump.link/cable'
WEBSOCKET_URL_DEV =
'ws://localhost:3000/cable'

Instance Method Summary collapse

Instance Method Details

#forward(webhookdump_id, forward_url) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/webhook_dump.rb', line 16

def forward(webhookdump_id, forward_url)
  EM.run do
    puts "Start forwarding events from WebhookDump #{webhookdump_id} to #{forward_url}"

    ws = init_faye_websocket_connection(webhookdump_id)

    open_websocket_connection(ws)

    handle_incoming_message(ws, forward_url)

    close_websocket_connection(ws)
  rescue => e
    puts "Error in EventMachine: #{e.message}"
  end
end