Created
January 15, 2010 01:06
-
-
Save rjungemann/277677 to your computer and use it in GitHub Desktop.
Use Spork to create an HTTP server in Ruby with a socket component
This file contains hidden or 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
# use "git clone git://github.com/deadprogrammer/spork.git" to install | |
# spork into your directory | |
require 'rubygems' | |
require 'eventmachine' | |
require 'rocket-amf/lib/rocketamf' | |
require 'spork' | |
module SocketSampleServer | |
def post_init | |
puts "Connecting: someone connected to the echo server!" | |
end | |
def receive_data datainspect | |
send_data "Hello, again!" | |
end | |
end | |
Spork.spork(:log => @log) do | |
EventMachine::run do | |
EventMachine::start_server "127.0.0.1", 8081, SocketSampleServer | |
end | |
end | |
run Rack::URLMap.new( | |
"/" => Rack::File.new("assets") | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment