Created
August 9, 2011 07:04
-
-
Save dariocravero/1133536 to your computer and use it in GitHub Desktop.
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
#!/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 |
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
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