Method: Rocket::Server::Connection#onopen
- Defined in:
- lib/rocket/server/connection.rb
#onopen ⇒ Object
Starts new session for application specified in request path.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rocket/server/connection.rb', line 39 def onopen ok = false request["Path"] =~ APP_PATH_PATTERN if @session = Session.new($1) log_debug(:opening_connection, app_id, signature) if secret = request["Query"]["secret"] if @session.authenticate!(secret) ok = true log_debug(:auth_success, app_id, signature) else log_debug(:auth_error, app_id, signature) end else ok = true end end send({:event => 'rocket:connected', :data => { :session_id => signature }}.to_json) if ok return ok rescue App::NotFoundError => ex log_error(:app_not_found_error, signature, ex.to_s) close_connection end |