Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added agents functionality. It doesn't work well.

  • Loading branch information...
commit 52122e6cc3039ab2e6455c13e7eefdbc076e8870 1 parent e6e5809
@danopia authored
Showing with 27 additions and 9 deletions.
  1. +9 −0 agents/echoey.rb
  2. +15 −9 lib/delta.rb
  3. +3 −0  xmpp_component.rb
View
9 agents/echoey.rb
@@ -0,0 +1,9 @@
+class Echoey# < Sails::Agent
+ def handle remote, wave, blip
+ if blip
+ Sails::Delta.build remote, wave, 'echoey@danopia.net' do |builder|
+ builder.new_blip_under blip, blip.contents.gsub("\001", '')
+ end
+ end
+ end
+end
View
24 lib/delta.rb
@@ -249,21 +249,27 @@ def propagate(applied=false)
# Don't send back to ourselfs
targets.delete @wave.provider.domain
- return if targets.empty?
+ unless targets.empty?
- packet = "<request xmlns=\"urn:xmpp:receipts\"/><event xmlns=\"http://jabber.org/protocol/pubsub#event\"><items><item><wavelet-update xmlns=\"http://waveprotocol.org/protocol/0.2/waveserver\" wavelet-name=\"#{@wave.conv_root_path}\"><applied-delta><![CDATA[#{encode64(self.to_applied)}]]></applied-delta></wavelet-update></item></items></event>"
-
- puts "Sending to #{targets.join(', ')}"
-
- targets.uniq.each do |target|
- server = @wave.provider.find_or_create_server target
- puts "Handing off a packet for #{server.name}"
- server << ['message', 'normal', packet]
+ packet = "<request xmlns=\"urn:xmpp:receipts\"/><event xmlns=\"http://jabber.org/protocol/pubsub#event\"><items><item><wavelet-update xmlns=\"http://waveprotocol.org/protocol/0.2/waveserver\" wavelet-name=\"#{@wave.conv_root_path}\"><applied-delta><![CDATA[#{encode64(self.to_applied)}]]></applied-delta></wavelet-update></item></items></event>"
+
+ puts "Sending to #{targets.join(', ')}"
+
+ targets.uniq.each do |target|
+ server = @wave.provider.find_or_create_server target
+ puts "Handing off a packet for #{server.name}"
+ server << ['message', 'normal', packet]
+ end
end
else # Then it's remote; send out the request
@wave.post self
end
+
+ unless @author == 'echoey@danopia.net'
+ puts 'poking Echoey' if @wave.participants.include? 'echoey@danopia.net'
+ Echoey.new.handle $remote, @wave, @operations.select {|op| op.is_a? Operations::Mutate }.map {|op| @wave.blip(op.document_id) }.uniq.first if @wave.participants.include? 'echoey@danopia.net'
+ end
end
def self.build remote, wave, author, &block
View
3  xmpp_component.rb
@@ -7,6 +7,8 @@
require 'sails'
include Sails
+require 'agents/echoey'
+
puts "Loading config"
begin
config = YAML.load(File.open('sails.conf'))
@@ -52,6 +54,7 @@
provider.send_data "<handshake>#{key}</handshake>"
remote = SailsRemote.serve(provider)
+$remote = remote
puts "DRb server running at #{remote.uri}"
trap("INT") do
Please sign in to comment.
Something went wrong with that request. Please try again.