]> Dogcows Code - chaz/chatty/commitdiff
add model for interacting with meteord
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Wed, 4 Jan 2012 02:34:03 +0000 (19:34 -0700)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Wed, 4 Jan 2012 02:34:03 +0000 (19:34 -0700)
lib/Chatty/Model/Meteor.pm [new file with mode: 0644]
t/model_Meteor.t [new file with mode: 0644]

diff --git a/lib/Chatty/Model/Meteor.pm b/lib/Chatty/Model/Meteor.pm
new file mode 100644 (file)
index 0000000..75d90b3
--- /dev/null
@@ -0,0 +1,57 @@
+package Chatty::Model::Meteor;
+use Moose;
+use namespace::autoclean;
+
+use IO::Socket;
+
+extends 'Catalyst::Model';
+
+# TODO: does not reconnect to cometd if connection is broken
+has 'cnx' => (
+       is => 'ro',
+       lazy => 1,
+       required => 1,
+       default => sub {
+               IO::Socket::INET->new(
+                       PeerAddr => 'localhost',
+                       PeerPort => 4671,
+                       Proto => 'tcp'
+               );
+       },
+);
+
+=head1 NAME
+
+Chatty::Model::Meteor - Catalyst Model
+
+=head1 DESCRIPTION
+
+Handles interaction with the meteor comet server.
+
+=head1 METHODS
+
+=head2 addMessage
+
+Post a message to the server.
+
+=cut
+
+sub addMessage {
+       my ($self, $channel, $message) = @_;
+       my $cnx = $self->cnx;
+       print $cnx "ADDMESSAGE $channel $message\n";
+}
+
+=head1 AUTHOR
+
+Charles McGarvey
+
+=head1 LICENSE
+
+This library is free software. You can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+__PACKAGE__->meta->make_immutable;
+1;
diff --git a/t/model_Meteor.t b/t/model_Meteor.t
new file mode 100644 (file)
index 0000000..72a5bb5
--- /dev/null
@@ -0,0 +1,8 @@
+use strict;
+use warnings;
+use Test::More;
+
+
+BEGIN { use_ok 'Chatty::Model::Meteor' }
+
+done_testing();
This page took 0.027832 seconds and 4 git commands to generate.