Skip to content

Instantly share code, notes, and snippets.

@dariocravero
Created August 9, 2011 07:04
Show Gist options
  • Save dariocravero/1133536 to your computer and use it in GitHub Desktop.
Save dariocravero/1133536 to your computer and use it in GitHub Desktop.
#!/usr/bin/env rackup
# encoding: utf-8
# This file can be used to start Padrino,
# just execute it from the command line.
require File.expand_path("../config/boot.rb", __FILE__)
require File.join(PADRINO_ROOT, "app/sockets.rb")
map "/sockets" do
run WheresMyMoneySockets.new
end
map "/" do
run Padrino.application
end
class WheresMyMoneySockets < Rack::WebSocket::Application
def on_open(env)
p "Connected"
send_data "Hi! :)"
p Sessions.current_account
end
def on_close(env)
p "Disconnected"
send_data "Bye!"
end
def on_message(env, message)
p "Message: #{message}"
send_data "Echo #{message}"
end
def on_error(env, error)
p "Error: #{error}"
send_data "Echo #{error}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment