Sha256: 7ccdbce285e1ce71758901afd427b344cc01dcabb7eff04f6030aa7e7922c0fe

Contents?: true

Size: 761 Bytes

Versions: 3

Compression:

Stored size: 761 Bytes

Contents

WebSocketIO.on :connect do |session|
  puts "new client <#{session}>"
  WebSocketIO.push :chat, {:name => "system", :message => "new client <#{session}> / #{WebSocketIO.sessions.size} clients connecting"}
  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.6 sample/main.rb
sinatra-websocketio-0.0.5 sample/main.rb
sinatra-websocketio-0.0.4 sample/main.rb