谁能给个rails+webSocket的简单应用例子

yipingshui2011 2012-02-16 09:22:01
谁能给个rails+webSocket的简单应用例子?
...全文
344 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
fqf530854528 2012-08-01
  • 打赏
  • 举报
回复
楼主,你找到的例子的地址是?
梦幻星云 2012-06-29
  • 打赏
  • 举报
回复
楼主把rails+webSocket的简单应用例子发下啊
yipingshui2011 2012-03-22
  • 打赏
  • 举报
回复
谢谢! 我在github中找到例子了
xianqiang1 2012-03-06
  • 打赏
  • 举报
回复
错了啊!我将webSocket看成webService了,唉!丢大了。。
当是帮你项一下,上面的是个笑话!
xianqiang1 2012-03-06
  • 打赏
  • 举报
回复
class HelloWorld
attr_reader :hello

def initialize
@hello = "Hello Ruby Web Services!!"
end

def printToScreen(str)
puts str
end
end
xianqiang1 2012-03-06
  • 打赏
  • 举报
回复
不知道Rails怎样实现,但看了一下ruby的实现方式(参考Programming Ruby),希望对你有帮助:
service:
require 'soap/rpc/standaloneServer'
require 'HelloWorld'

NS = "http://test.websoft.com/hello"

class Server2 < SOAP::RPC::StandaloneServer
def on_init
hello = HelloWorld.new
add_method(hello, 'hello')
add_method(hello, "printToScreen", 'str')
end
end

svr = Server2.new('hello', NS, '0.0.0.0', 3000)
trap('INT') { svr.shutdown }
svr.start

client:
require 'soap/rpc/driver'
proxy = SOAP::RPC::Driver.new("http://localhost:3000",
"http://test.websoft.com/hello")

proxy.add_method('hello')
proxy.add_method('printToScreen', 'str')

puts "#{ proxy.hello }"

proxy.printToScreen("Test for Web Services !!")

希望知道rails的大侠帮忙一下,我也不希望这个帖子沉了!!

2,764

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ruby/Rails
社区管理员
  • Ruby/Rails社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧