Class: ActionFramework::Realtime

Inherits:
Rack::WebSocket::Application
  • Object
show all
Defined in:
lib/actionframework/realtime.rb

Instance Method Summary collapse

Constructor Details

#initializeRealtime

Returns a new instance of Realtime.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/actionframework/realtime.rb', line 12

def initialize
	super
	@nosocket = true

	begin 
		socket = UNIXSocket.new("./realtime.socket")
		@nosocket = false
		@message = ActionFramework::RealtimeMessage.new(socket)
	rescue
		
	end
end

Instance Method Details

#exit_meObject



38
39
40
# File 'lib/actionframework/realtime.rb', line 38

def exit_me
	puts "INFO: No Unix Socket found, your application doesn't implement the realtime API"
end

#on_close(env) ⇒ Object



30
31
32
# File 'lib/actionframework/realtime.rb', line 30

def on_close env
	
end

#on_message(env, msg) ⇒ Object



34
35
36
# File 'lib/actionframework/realtime.rb', line 34

def on_message env,msg
	@message.post("client_message",{:env => env,:msg => msg})
end

#on_open(env) ⇒ Object



25
26
27
28
# File 'lib/actionframework/realtime.rb', line 25

def on_open env
	return exit_me unless @nosocket
	@message.post("client_connected",{:env => env,:msg => msg})
end