Created
July 21, 2018 21:21
-
-
Save mediamagnet/138aae2fcc907659c5af7e3c626dc79c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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