Permalink
Browse files

minor tweaks

  • Loading branch information...
1 parent 9f03a30 commit 144c95c6020cb1992726a0130aaa674837353a57 @adrianpike committed Dec 14, 2011
Showing with 14 additions and 11 deletions.
  1. +6 −5 README.rdoc
  2. +0 −1 lib/barnacle/peer_handler.rb
  3. +8 −5 lib/barnacle/server_handler.rb
View
@@ -1,4 +1,4 @@
-=== barnacle ===
+= barnacle
Barnacle is a gossip library for Ruby.
@@ -7,13 +7,13 @@ get it?
Barnacle handles discovery and message passing.
-== Quickstart ==
+== Quickstart
Take a look at example.rb, and start it up on two machines.
On the second machine you start up, use the IP of the first one as the first argument.
Now fire it up on any other machines, point it anywhere in the network, and watch the magic happen!
-== Node Lifecycle ==
+== Node Lifecycle
- Discover peers, join the graph.
- Replace slow peer links with faster links.
- Maintain connectivity!
@@ -22,13 +22,14 @@ Now fire it up on any other machines, point it anywhere in the network, and watc
- Take care of any loops.
- Specify a subset of nodes, or send to _everybody_.
-== TODO ==
+== TODO
- Actually finish it, and bring in the tests
- Logger
- Modularize node discovery channels
+ - Need zeroconf like stat.
- Modularize messaging protocol
- Rewrite traversal so it's more efficient
- GC the message sent list with timestamps
- Disconnections
- - Handle ports on servers
+ - Handle finding an open port on servers
- Handle reconnections
@@ -30,7 +30,6 @@ def receive_data(data)
end
when :node_request
# They asked for more nodes, let's give them some.
-
when :app_message
# Pass it to the App, and pass it on to other nodes if needed.
@node.server.rebroadcast_message(m, @node.uuid)
@@ -22,18 +22,21 @@ def receive_data(data)
m = Message.new(data)
case m.type
when :node_identification
- if @server.peers[m.key] or m.key == @server.uuid then
-
- else
+ unless @server.peers[m.key] or m.key == @server.uuid then # We already know about them!
# The client just let us know who they were.
- port, ip = Socket.unpack_sockaddr_in(get_peername)
-
+ if (m.value) then
+ ip = m.value
+ else
+ port, ip = Socket.unpack_sockaddr_in(get_peername)
+ end
+ # TODO: use port correctly :/
n = Peer.new(:host => ip, :uuid => m.key, :connection => self)
@remote_uuid = m.key
@server.peers[m.key] = n
end
when :node_request
# They asked for more nodes, let's give them some.
+ # We're going to send them a bunch of :node_identification messages!
when :app_message
# Pass it to the App, and pass it on to other nodes if needed.

0 comments on commit 144c95c

Please sign in to comment.