Class: Rubko::Socket

Inherits:
Controller show all
Defined in:
lib/rubko/socket.rb

Instance Attribute Summary

Attributes included from Base

#parent

Instance Method Summary collapse

Methods inherited from Controller

#index, #other

Methods included from Base

#camelize, #httpGet, #init, #jsonParse, #loadController, #loadFile, #loadModel, #loadPlugin, #loadView, #method_missing, #uncamelize

Constructor Details

#initializeSocket

Returns a new instance of Socket.



7
8
9
10
11
12
13
14
15
16
# File 'lib/rubko/socket.rb', line 7

def initialize(*)
	super
	if Faye::WebSocket.websocket?(env)
		@ws = Faye::WebSocket.new env#, [], ping: 10*60
		@ws.onclose = -> event {
			p [:close, event.code, event.reason]
			@ws = nil
		}
	end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rubko::Base

Instance Method Details

#compressible?Boolean

Returns:

  • (Boolean)


22
# File 'lib/rubko/socket.rb', line 22

def compressible?; false end

#finalizeObject



18
19
20
# File 'lib/rubko/socket.rb', line 18

def finalize
	self.status, self.headers, self.body = *@ws.rack_response if @ws
end