29/04/13 17:19
giordanomalandra
da ieri ho iniziato a programmare in ruby ho copiato questo codice da html.it ma mi da errore
la libreria em-websocket è installata
require 'rubygems' require 'em-websocket' EventMachine.run { @channels = Hash.new {|h,k| h[k] = EM::Channel.new } EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080, :debug => true) do | ws| ws.onopen do sid = nil fiveboard_channel = nil ws.onmessage do |msg| command, value = msg.split(":", 2); case command when 'registra' fiveboard_channel = @channels[value] sid = fiveboard_channel.subscribe { |txt| ws.send(txt) } when 'aggiorna' fiveboard_channel.push('testo:' + value) end end ws.onclose do fiveboard_channel.unsubscribe(sid) end end end puts "Il server è correttamente partito" }
la libreria em-websocket è installata
aaa