草庐IT

EventMachine

全部标签

ruby - EventMachine WebSockets - 订阅 EM channel 与保持套接字在集合中

我正在构建一个使用EM和WebSockets并涉及向订阅的客户端广播数据的项目。我想知道为什么人们更喜欢订阅一个websocket到一个channel,如下所示:EventMachine::WebSocket.start(:host=>"0.0.0.0",:port=>8080)do|ws|ws.onopen{sid=@channel.subscribe{|msg|ws.sendmsg}@channel.push"#{sid}connected!"ws.onmessage{|msg|@channel.push":#{msg}"}ws.onclose{@channel.unsubscri

ruby - EventMachine 如何编写对按键使用react的键盘处理程序

我使用EventMachineLineText2协议(protocol),我想在每次按下键盘上的字符时触发receive_line方法,而不仅仅是在输入新行时触发。有没有办法改变这种默认行为?classKeyboardHandler 最佳答案 如果你想从终端接收无缓冲的输入,你应该关闭标准输入的规范模式。(我还关闭了echo以使屏幕更易于阅读。)在您的代码调用#open_keyboard之前或在您的处理程序初始化程序中添加:require'termios'#...attributes=Termios.tcgetattr($stdin

ruby - 使用 EventMachine 的 SOAP 调用

有什么方法可以在EventMachine中发出非阻塞SOAP请求吗?我正在使用adwords4rgem创建一个与googleadwordsapi(基于SOAP)交互的ruby​​应用程序。该应用程序使用EM通过stomp连接接收消息,然后通过对adwordsapi进行SOAP调用来处理这些消息。显然我需要这些调用是非阻塞的,因为处理将在react器线程内进行。一种选择是使用EM.defer,但我不希望线程池中有一堆线程的开销。 最佳答案 HandSoap可以使用EventMachine。

ruby - QtRuby 与 DRb 或 EventMachine

我想使用Qt在Ruby中编写一个应用程序,它将通过网络与其他实例进行通信。如何将Qt的事件循环与DRb或EventMachine集成?编辑:当我有更多时间时,我找到了答案,我会发布它 最佳答案 require'eventmachine'require'Qt4'app=Qt::Application.new(ARGV)hello_button=Qt::PushButton.new("HelloEventMachine")hello_button.resize(100,20)hello_button.showEventMachine.r

ruby-on-rails - ruby rails : "cannot load such file" eventmachine

我正在尝试在我的Windows机器上运行RoR应用程序。我在配置所有内容方面取得了很大进展,但我被困在这里。当我尝试运行rake时,出现以下错误:C:\inetpub\wwwroot\voterApp>railsserverC:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in`require':cannotloadsuchfile--eventmachine(LoadError)fromC:/Ruby/lib/ruby/gems/1.9.1/gems/

ruby - 如何在同一个 EventMachine react 器中运行 Net::SSH 和 AMQP?

一些背景:GerritexposesaneventstreamthroughSSH.这是一个可爱的技巧,但我需要将这些事件转换为AMQP消息。我试着用ruby-amqp做到这一点和Net::SSH但是,好吧,AMQP子组件似乎根本没有在运行。我是EventMachine的新手。有人可以指出我做错了什么吗?“MultipleserversinasingleEventMachinereactor”的答案似乎不适用。该程序也可以在gist中找到以便于访问,它是:#!/usr/bin/envrubyrequire'rubygems'require'optparse'require'net/ss

ruby - 是否可以使用 EventMachine 和 Ruby 1.8 发起多个并行 http 请求

em-synchrony.rb使用Fibres实现了此功能,但我会选择具有1.8MRI的非Fibre版本。EM.rundohttp=EM::Protocols::HttpClient2.connect("www.google.com",80)request=http.get("/")request.callbackdoputsrequest.statusEM.stopendend 最佳答案 看看em-http-request:EM.rundohttp1=EventMachine::HttpRequest.new('http://ex

ruby-on-rails - 安装 eventmachine gem 时出错

当我运行foremanstart时,出现以下错误:pallav@pallav-System-Product-Name:~/Workspace/Aadvisor$foremanstart10:04:32web.1|startedwithpid1102210:04:32web.1|/var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in`blockinmaterialize':Couldnotfindeventmachine-0.12.10inanyofthesources(Bundler::GemNotFou

ruby - 使用 thin & eventmachine 的 HTTP 流式传输

我在玩EM,实现流式和并发。我在流式传输时遇到问题...我运行以下机架应用程序https://gist.github.com/1394840使用$rackup-sthin-p3000async_app.ru在使用$ab-c10-n20http://localhost:3000/进行测试时,该应用程序似乎接受了并行请求。太棒了!我希望它能同时实现流式传输。当我在Firefox8中测试它时,它工作得很好。并使用$curl-ihttp://localhost:3000/,结果也按预期流式传输!但后来在IE和Chrome中测试时,流式传输失败,即三行在请求触发后5秒才一起出现...我怀疑是不是

ruby - Github 服务/Ruby Gem "eventmachine"Mac 安装问题

我认为这不是特别重要,但我的Github服务存储库分支是https://github.com/franklovecchio/github-services当我尝试运行“sudoruby​​github-services.rb”来测试我的钩子(Hook)时,它会尝试安装eventmachine,这会出现以下错误(我可以安装其他gem!)。我也完成了gemupdate,但仍然出现相同的错误。bundlergem也已安装。有人看到了吗?sudorubygithub-services.rbPassword:WARNThegemenvironmentisout-of-dateorhasyetto