class ActionFramework::Realtime

Public Class Methods

configure() { |$realtime_config| ... } click to toggle source
# File lib/actionframework/realtime.rb, line 51
def self.configure
        $realtime_config = RealtimeConfigure.new
        yield($realtime_config)
end

Public Instance Methods

call(env) click to toggle source
# File lib/actionframework/realtime.rb, line 16
def call(env)
                tubesock = Tubesock.hijack(env)
                tubesock.listen
                
                @sock = tubesock

                tubesock.onmessage do |message|
                        on_message(env,message);
                end

                tubesock.onopen do
                        on_open(env)
                end

                tubesock.onclose do
                        on_close(env)
                end
    [ -1, {}, [] ]
end
on_close(env) click to toggle source
# File lib/actionframework/realtime.rb, line 46
def on_close(env)
        request = Rack::Request.new(env)
        perform_action(env,request,request.path,"on_close",nil)
end
on_message(env,message) click to toggle source
# File lib/actionframework/realtime.rb, line 41
def on_message(env,message)
        request = Rack::Request.new(env)
        perform_action(env,request,request.path,"on_message",message)
end
on_open(env) click to toggle source
# File lib/actionframework/realtime.rb, line 36
def on_open(env)
        request = Rack::Request.new(env)
        perform_action(env,request,request.path,"on_open",nil)
end
perform_action(env,req,path,method,payload) click to toggle source
# File lib/actionframework/realtime.rb, line 57
def perform_action(env,req,path,method,payload)
        matchedroute = ActionFramework::Server.current.routesklass.route(path,"realtime")
        controller,url = matchedroute[0],matchedroute[1]

        Object.const_get(controller).new(url,req,env,payload,@sock).send(method,payload)
end