rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob c68f493a3a69cba96e231a0975345b57045a7a0f 570 bytes (raw)
$ git show HEAD:t/cramp/rainsocket.ru	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
# based on examples/rainsocket.ru git://github.com/lifo/cramp
# Rack::Lint does not like async + EM stuff, so disable it:
#\ -E deployment
require 'cramp'

Cramp::Websocket.backend = :rainbows

class WelcomeController < Cramp::Websocket
  periodic_timer :send_hello_world, :every => 2
  on_data :received_data

  def received_data(data)
    if data =~ /fuck/
      render "You cant say fuck in here"
      finish
    else
      render "Got your #{data}"
    end
  end

  def send_hello_world
    render("Hello from the Server!\n" * 256)
  end
end

run WelcomeController

git clone https://yhbt.net/rainbows.git