module Padrino::WebSockets::Faye::Routing
Public Instance Methods
websocket(channel, *args, &block)
click to toggle source
Creates a WebSocket endpoint using SpiderGazelle
+ libuv.
It handles upgrading the HTTP connection for you. You can nest this inside controllers as you would do with regular actions in Padrino
.
# File lib/padrino-websockets/faye/routing.rb, line 13 def websocket(channel, *args, &block) get channel, *args do # Let some other action try to handle the request if it's not a WebSocket. throw :pass unless ::Faye::WebSocket.websocket?(request.env) set_websocket_user ws = ::Faye::WebSocket.new(env, nil, {ping: 15}) Padrino::WebSockets::Faye::EventManager.new(params[:channel] || channel, session['websocket_user'], ws, self, &block) ws.rack_response end end
Also aliased as: ws