Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Ruby - websocket con ruby
Forum - Ruby - websocket con ruby

Avatar
giordanomalandra (Normal User)
Newbie


Messaggi: 15
Iscritto: 29/09/2012

Segnala al moderatore
Postato alle 19:19
Lunedì, 29/04/2013
da ieri ho iniziato a programmare in ruby ho copiato questo codice da html.it ma mi da errore
Codice sorgente - presumibilmente Delphi

  1. require 'rubygems'
  2. require 'em-websocket'
  3.  
  4. EventMachine.run {
  5.   @channels = Hash.new {|h,k| h[k] = EM::Channel.new }
  6.   EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080, :debug => true) do |
  7.   ws|
  8.      
  9.     ws.onopen do
  10.       sid = nil
  11.       fiveboard_channel = nil
  12.  
  13.     ws.onmessage do |msg|
  14.       command, value = msg.split(":", 2);
  15.       case command
  16.         when 'registra'
  17.           fiveboard_channel = @channels[value]
  18.           sid = fiveboard_channel.subscribe { |txt| ws.send(txt) }
  19.         when 'aggiorna'
  20.           fiveboard_channel.push('testo:' + value)
  21.       end
  22.     end
  23.  
  24.     ws.onclose do
  25.       fiveboard_channel.unsubscribe(sid)
  26.     end
  27.   end
  28. end
  29. puts "Il server è correttamente partito"
  30. }


la libreria em-websocket è installata

PM Quote
Avatar
pierotofy (Admin)
Guru^2


Messaggi: 6230
Iscritto: 04/12/2003

Segnala al moderatore
Postato alle 20:26
Lunedì, 29/04/2013
Prova ad usare la versione 1.9.3 di Ruby a 32bit. Potrebbe essere un problema della versione che stai usando.


Il mio blog: https://piero.dev
PM Quote
Avatar
giordanomalandra (Normal User)
Newbie


Messaggi: 15
Iscritto: 29/09/2012

Segnala al moderatore
Postato alle 13:54
Martedì, 30/04/2013
non funziona

PM Quote