strict;
#use AnyEvent::Impl::Perl;
use AnyEvent;
use AnyEvent::IRC::Client;
use Data::Dumper;
use JSON;
use Padre::Swarm::Transport::Multicast;
my $gatewayid = rand() . $$;
my $swarm = Padre::Swarm::
w(
fh => $socket,
on_eof => sub { $swarm->shutdown },
on_read => sub { $_[0]->push_read( json => \&swarm_relay ) ; },
on_error => sub { warn "Error @_ " },
);
my $con = AnyEvent::IRC:
entity => $con->nick, };
$swarm->tell_channel( 12000, JSON::encode_json $msg );
#$io->push_write( json => $msg );
}
);
$con->connect ("irc.perl.org", 6667 ,
{ nick => $ni
package Padre::Plugin::Swarm::Transport::Local::Multicast::Service;
use strict;
use warnings;
use JSON;
use Padre::Wx ();
use Padre::Task ();
use Padre::Logger;
use Padre::Swarm::Message;
use IO:
ocal $ENV{PERL_ANYEVENT_MODEL} = 'Perl';
require AnyEvent;
require IO::Socket::Multicast;
require JSON;
my $bailout = AnyEvent->condvar;
my $timer = AnyEvent->timer( interval => $freq , cb => \
ined(my $m = $q->dequeue_nb) ) {
print STDERR "Got message '$m'";
my $msg = JSON::encode_json( { type=>'chat' , body=>$m , from=>$0.$$ } );
$c->mcast_send( $msg , '239.255.255.
{
my $self = shift;
$self->{origin} = shift if @_;
return $self->{origin};
}
sub TO_JSON {
## really should be the canonical identity
my $self = shift;
my $ref = { %$self } ; # erm -
ocal $ENV{PERL_ANYEVENT_MODEL} = 'Perl';
require AnyEvent;
require IO::Socket::Multicast;
require JSON;
my $bailout = AnyEvent->condvar;
my $timer = AnyEvent->timer( interval => $freq , cb => \
ined(my $m = $q->dequeue_nb) ) {
print STDERR "Got message '$m'";
my $msg = JSON::encode_json( { type=>'chat' , body=>$m , from=>$0.$$ } );
$c->mcast_send( $msg , '239.255.255.
hift;
my $message = shift;
my @s = $self->graph->successors( $message->{from} );
$self->graph->delete_vertex( $_ )
for @s, $message->{from};
}
sub TO_JSON {
}
sub FROM_JSON {
}
1;
Object::Event );
use AnyEvent::Handle;
use IO::Socket::Multicast;
use Padre::Swarm::Message;
use JSON;
our $VERSION = '0.2';
=pod
=head1 NAME
Padre::Plugin::Swarm::Transport::Local - Multicast swa
);
}
$self->unreg_me;
}
sub _marshal {
JSON->new
->allow_blessed
->convert_blessed
->utf8
->filter_json_object(\&synthetic_class );
}
sub synthetic_class
adre::Swarm::Message;
use AnyEvent::Socket;
use AnyEvent::Handle;
use Scalar::Util 'blessed';
use JSON;
our $VERSION = '0.2';
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
d ' . $!);
return;
}
my $h = AnyEvent::Handle->new(
fh => $fh,
json => $self->_marshal,
on_eof => sub { $self->event('disconnect', shift ) },
);
connect', \&disconnect );
$self->{h} = $h;
$h->push_write( json => { trustme=>$$.rand() } );
$h->push_read( json => sub { $self->event( 'see_auth' , @_ ) } );
$self->reg_cb( 'see_
package Padre::Plugin::Swarm::Transport;
use strict;
use warnings;
use Padre::Logger;
use JSON::PP;
use base 'Object::Event';
use Class::XSAccessor
accessors => {
marshal => 'marshal',
on_
age - $@" ) if DEBUG;
}
}
sub _marshal {
JSON::PP->new
->allow_blessed
->convert_blessed
->utf8
->filter_json_object(\&synthetic_class );
}
sub syntheti
strict;
use AnyEvent;
use AnyEvent::Socket;
use AnyEvent::Handle;
use IO::Socket::Multicast;
use JSON;
use Carp qw( cluck );
$|++;
#use Padre::Swarm::Transport::Multicast;
#my $mc = Padre::Swarm::T
,
trustme => "relay-$$-".time(),
};
$swarm->push_write( json => $message );
$swarm->push_read( json => \&swarm_ready );
}
sub swarm_ready {
my ($handle ,$messag
$handle->push_write( json => {
type => 'promote',
from => $handle->{token},
service => 'relay',
} );
$handle->push_write( json => {
type => 'disco'