Created
April 5, 2013 02:41
-
-
Save digitalextremist/5316190 to your computer and use it in GitHub Desktop.
Sample Reel server, to cause reproducible error.
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 'rubygems' | |
require 'bundler/setup' | |
require 'reel' | |
class MyServer < Reel::Server | |
def initialize(host = "0.0.0.0", port = 80) | |
super(host, port, &method(:on_connection)) | |
end | |
def on_connection(connection) | |
while request = connection.request | |
case request | |
when Reel::Request | |
handle_request(request) | |
when Reel::WebSocket | |
handle_websocket(request) | |
end | |
end | |
end | |
def handle_request(request) | |
request.respond :ok, "Hello, world!" | |
end | |
def handle_websocket(sock) | |
sock << "Hello everyone out there in WebSocket land!" | |
sock.close | |
end | |
end | |
MyServer.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment