Skip to content

Instantly share code, notes, and snippets.

@mediamagnet
Created July 21, 2018 21:21
Show Gist options
  • Save mediamagnet/138aae2fcc907659c5af7e3c626dc79c to your computer and use it in GitHub Desktop.
Save mediamagnet/138aae2fcc907659c5af7e3c626dc79c to your computer and use it in GitHub Desktop.
require 'eventmachine'
require 'websocket-eventmachine-client'
EM.run do
ws = WebSocket::EventMachine::Client.connect(:uri => 'wss://irc-ws.chat.twitch.tv')
ws.onopen do
puts "Connected"
ws.send "CAP REQ :twitch.tv/tags twitch.tv/commands twitch.tv/membership"
ws.send "NICK justinfan#{rand(100000..999999)}"
ws.send "JOIN #dwangoac"
end
ws.onmessage do |msg, type|
puts "Received message: #{msg}"
end
ws.onclose do |code, reason|
puts "Disconnected with status code: #{code}"
end
ws.onping do |message|
puts "Ping received: #{message}"
end
EventMachine.next_tick do
ws.ping "Ping!"
end
end
#after running: Disconnected with status code: 1002
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment