Sha256: 487aac9b73605d45a97a029127048ec493230884586d18c8fd3c69af6d3f888a

Contents?: true

Size: 611 Bytes

Versions: 1

Compression:

Stored size: 611 Bytes

Contents

require 'lib/rack/websocket'

class MyApp < Rack::WebSocket::Application
  def on_open
    puts "client connected"
    EM.add_timer(5) do
      send_data "This message should show-up 5 secs later"
    end

    EM.add_timer(15) do
      send_data "This message should show-up 15 secs later"
    end
  end

  def on_message(msg)
    puts "message received: " + msg
    send_data "Hello #{msg}"
  end

  def on_close
    puts "client disconnected"
  end
end

# use Rack::CommonLogger

map '/' do
  use MyApp #, :websocket_debug => true

  run Rack::File.new(File.expand_path(File.dirname(__FILE__)) + '/html')
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
websocket-rack-0.1.2 example/example.ru