Skip to content

Instantly share code, notes, and snippets.

@typewriter
Created December 4, 2017 14:12
Show Gist options
  • Save typewriter/d3b42b9442f3ec964972864f6a4bb808 to your computer and use it in GitHub Desktop.
Save typewriter/d3b42b9442f3ec964972864f6a4bb808 to your computer and use it in GitHub Desktop.
Server Sent Events (SSE) Client with Ruby
# Server Sent Events (SSE) Windows Client sample
# (but cannot install/load em-eventsource)
require 'win32ole'
require 'em-eventsource'
# Windows Script Host :(
shell = WIN32OLE.new('Shell.Application')
wsh = WIN32OLE.new('Wscript.Shell')
EM.run do
source = EventMachine::EventSource.new("http://example.com:8080/subscribe")
source.message do |message|
shell.MinimizeAll
wsh.Run message
end
source.start
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment