Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

make the application weak ref

  • Loading branch information...
commit 90912dfec06885bad61f95a8c738d274bad893e6 1 parent 23e557b
@miyagawa authored
View
1  eg/xmppbot/app.psgi
@@ -31,6 +31,7 @@ sub on_response {
my $text = $result->{responseData}{translatedText};
$message->reply($text);
+ $self->finish;
}
package main;
View
7 lib/Tatsumaki/Application.pm
@@ -101,11 +101,8 @@ sub template_path {
sub add_service {
my($self, $service) = @_;
-
- my $application = $self;
- Scalar::Util::weaken($application);
- $service->start($application);
-
+ $service->application($self);
+ $service->start;
push @{$self->services}, $service;
}
View
2  lib/Tatsumaki/Service.pm
@@ -1,6 +1,6 @@
package Tatsumaki::Service;
use Moose;
-has application => (is => 'rw', isa => 'Tatsumaki::Application');
+has application => (is => 'rw', isa => 'Tatsumaki::Application', weak_ref => 1);
1;
View
2  lib/Tatsumaki/Service/XMPP.pm
@@ -36,6 +36,7 @@ sub _build_xmpp {
return unless $msg->any_body;
+ # TODO refactor this
my $req = POST "/_services/xmpp/chat", [ from => $msg->from, to => $acct->jid, body => $msg->body ];
my $env = $req->to_psgi;
$env->{'tatsumaki.xmpp'} = {
@@ -70,7 +71,6 @@ sub _build_xmpp {
sub start {
my($self, $application) = @_;
- $self->application($application);
$self->xmpp->start;
}
Please sign in to comment.
Something went wrong with that request. Please try again.