Class: ActionFramework::Realtime
- Inherits:
-
Rack::WebSocket::Application
- Object
- Rack::WebSocket::Application
- ActionFramework::Realtime
- Defined in:
- lib/actionframework/realtime.rb
Instance Method Summary collapse
- #exit_me ⇒ Object
-
#initialize ⇒ Realtime
constructor
A new instance of Realtime.
- #on_close(env) ⇒ Object
- #on_message(env, msg) ⇒ Object
- #on_open(env) ⇒ Object
Constructor Details
#initialize ⇒ Realtime
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_me ⇒ Object
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 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 |