]> Dogcows Code - chaz/chatty/blobdiff - lib/Chatty/Controller/Chat.pm
add comet support for real-time chatting
[chaz/chatty] / lib / Chatty / Controller / Chat.pm
index 9be0e796e28449eefb4e31fbaad02c3e7cef997d..911c127ed95b18229c059b5891e86599a57e9a6d 100644 (file)
@@ -92,7 +92,17 @@ sub view :Chained(room) :PathPart('') :Args(1) {
        $c->stash(room => $c->model('DB::Room')->find($room));
        $c->detach('/missing') if !$c->stash->{room};
 
-       $c->stash(messages => [$c->model('DB::Message')->search(room => $room)]);
+       my $name = $c->user->obj->username;
+
+       my $msg = $c->req->param('msg');
+       if ($msg) {
+               $c->model('Meteor')->addMessage($room, "$name: $msg");
+               $c->stash->{json} = \1;
+               $c->forward('View::JSON');
+               return;
+       }
+
+       $c->model('Meteor')->addMessage($room, "** $name has entered **");
 }
 
 =head1 AUTHOR
This page took 0.021209 seconds and 4 git commands to generate.