Sha256: 4141d2b09d5c0fbe30101f866604494048505605824c022436fac8a5bfe1389b

Contents?: true

Size: 711 Bytes

Versions: 3

Compression:

Stored size: 711 Bytes

Contents

WebSocketIO.on :connect do |session|
  puts "new client <#{session}>"
  WebSocketIO.push :chat, {:name => "system", :message => "new client <#{session}>"}
  WebSocketIO.push :chat, {:name => "system", :message => "welcome <#{session}>"}, {:to => session}
end

WebSocketIO.on :disconnect do |session|
  puts "disconnect client <#{session}>"
  WebSocketIO.push :chat, {:name => "system", :message => "bye <#{session}>"}
end

WebSocketIO.on :chat do |data, from|
  puts "#{data['name']} : #{data['message']}  (from:#{from})"
  WebSocketIO.push :chat, data
end

WebSocketIO.on :error do |err|
  STDERR.puts "error!! #{err}"
end

get '/' do
  haml :index
end

get '/:source.css' do
  scss params[:source].to_sym
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sinatra-websocketio-0.0.3 sample/main.rb
sinatra-websocketio-0.0.2 sample/main.rb
sinatra-websocketio-0.0.1 sample/main.rb