0
我尝试这种代码(从网上的文章在这里了:http://www.randomhacks.net/articles/2009/05/08/chat-client-ruby-amqp-eventmachine-shoes)红宝石AMQP未初始化的恒定误差
require 'rubygems' gem 'amqp' require 'mq' unless ARGV.length == 2 STDERR.puts "Usage: #{$0} " exit 1 end $channel, $nick = ARGV AMQP.start(:host => 'localhost') do $chat = MQ.topic('chat') # Print any messages on our channel. queue = MQ.queue($nick) queue.bind('chat', :key => $channel) queue.subscribe do |msg| if msg.index("#{$nick}:") != 0 puts msg end end # Forward console input to our channel. module KeyboardInput include EM::Protocols::LineText2 def receive_line data $chat.publish("#{$nick}: #{data}", :routing_key => $channel) end end EM.open_keyboard(KeyboardInput) end
,但最终出现以下错误:
chat.rb:11:in `': uninitialized constant AMQP (NameError)
在那之后,我试着不同的示例代码与我的开发环境中的AMQP,但都显示我的错误。所以问题不在代码中,我的开发环境问题。任何人都可以用我的开发环境指出我的问题。提前致谢。
嗨,我要重新安装它。我在Centos 5.4 – sparrow 2010-05-28 09:57:44
祝你好运,并在这里后,如果你卡住 – 2010-05-28 10:03:11
我得到同样的错误在Ubuntu(精确)。任何运气修复这个? – Poul 2013-12-17 03:06:00