Rainbows! 4.5.0 - hijacking support
[rainbows.git] / t / cramp / rainsocket.ru
blobc68f493a3a69cba96e231a0975345b57045a7a0f
1 # based on examples/rainsocket.ru git://github.com/lifo/cramp
2 # Rack::Lint does not like async + EM stuff, so disable it:
3 #\ -E deployment
4 require 'cramp'
6 Cramp::Websocket.backend = :rainbows
8 class WelcomeController < Cramp::Websocket
9   periodic_timer :send_hello_world, :every => 2
10   on_data :received_data
12   def received_data(data)
13     if data =~ /fuck/
14       render "You cant say fuck in here"
15       finish
16     else
17       render "Got your #{data}"
18     end
19   end
21   def send_hello_world
22     render("Hello from the Server!\n" * 256)
23   end
24 end
26 run WelcomeController