Revision: 4541 http://trac.macosforge.org/projects/ruby/changeset/4541 Author: watson1978@gmail.com Date: 2010-09-27 04:39:02 -0700 (Mon, 27 Sep 2010) Log Message: ----------- Added the exsample that use WEBrick and Bonjour. Added Paths: ----------- MacRuby/trunk/sample-macruby/Scripts/webrick.rb Added: MacRuby/trunk/sample-macruby/Scripts/webrick.rb =================================================================== --- MacRuby/trunk/sample-macruby/Scripts/webrick.rb (rev 0) +++ MacRuby/trunk/sample-macruby/Scripts/webrick.rb 2010-09-27 11:39:02 UTC (rev 4541) @@ -0,0 +1,22 @@ +#!/usr/local/bin/macruby +# -*- coding: utf-8 -*- +# This script is sample of WEBrick and Bonjour. +# You could look for this server using Bonjour on Safari. +framework "Foundation" +require "webrick" + +DOC_ROOT = "." +SERVER_PORT = 8000 +SERVER_NAME = "webrick" + +s = WEBrick::HTTPServer.new( + :Port => SERVER_PORT, + :DocumentRoot => File.join(Dir::pwd, DOC_ROOT) +) +trap("INT") { s.shutdown } + +# Bonjour +netservice = NSNetService.alloc.initWithDomain("", type:"_http._tcp", name:SERVER_NAME, port:SERVER_PORT) +netservice.publish() + +s.start Property changes on: MacRuby/trunk/sample-macruby/Scripts/webrick.rb ___________________________________________________________________ Added: svn:executable + *