README in rev-0.2.2 vs README in rev-0.2.3
- old
+ new
@@ -16,14 +16,20 @@
For more information, consult the RubyForge page:
http://rev.rubyforge.org
+http://rubyforge.org/projects/rev
+
Questions? Sign up for the mailing list at:
http://rubyforge.org/mailman/listinfo/rev-talk
+The latest development code is available via github at:
+
+git://github.com/tarcieri/rev.git
+
== Anatomy
Rev builds on two core classes which bind to the libev API:
* Rev::Loop - This class represents an event loop which uses underlying high
@@ -86,10 +92,11 @@
== Example Program
Below is an example of how to write an echo server:
+ require 'rev'
HOST = 'localhost'
PORT = 4321
class EchoServerConnection < Rev::TCPSocket
def on_connect
@@ -103,11 +110,11 @@
def on_read(data)
write data
end
end
- server = Rev::TCPServer.new('localhost', PORT, EchoServerConnection)
+ server = Rev::TCPServer.new(HOST, PORT, EchoServerConnection)
server.attach(Rev::Loop.default)
puts "Echo server listening on #{HOST}:#{PORT}"
Rev::Loop.default.run
@@ -127,18 +134,18 @@
gives you the ability to change event callbacks on the fly (provided you
haven't overridden them in a subclass). This is especially useful for small
one off programs or just experimenting with the API.
Any callback (methods prefixed with on_*) can be set on the fly by passing it
-a block. (NOTE: Ruby 1.9 only)
+a block. (NOTE: Ruby 1.9/1.8.7 only)
Below is an example of using this syntax. It implements an echo server
identical to the one above:
HOST = '127.0.0.1'
PORT = 4321
- server = Rev::TCPServer.new(ADDR, PORT) do |c|
+ server = Rev::TCPServer.new(HOST, PORT) do |c|
c.on_connect { puts "#{remote_addr}:#{remote_port} connected" }
c.on_close { puts "#{remote_addr}:#{remote_port} disconnected" }
c.on_read { |data| write data }
end