/[meteor]/trunk/Meteor/Message.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/Meteor/Message.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (hide annotations)
Sun May 20 19:40:53 2007 UTC (12 years, 6 months ago) by knops.gerd
Original Path: googlecode.com/svn/trunk/Meteor/Message.pm
File size: 2816 byte(s)
• Add simple statistics, available via new SHOWSTATS controller command

1 knops.gerd 11 #!/usr/bin/perl -w
2     ###############################################################################
3     # Meteor
4     # An HTTP server for the 2.0 web
5     # Copyright (c) 2006 contributing authors
6     #
7     # Subscriber.pm
8     #
9     # Description:
10     # Meteor message object
11     #
12     ###############################################################################
13     #
14     # This program is free software; you can redistribute it and/or modify it
15     # under the terms of the GNU General Public License as published by the Free
16     # Software Foundation; either version 2 of the License, or (at your option)
17     # any later version.
18     #
19     # This program is distributed in the hope that it will be useful, but WITHOUT
20     # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21     # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
22     # more details.
23     #
24     # You should have received a copy of the GNU General Public License along
25     # with this program; if not, write to the Free Software Foundation, Inc.,
26     # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27     #
28     # For more information visit www.meteorserver.org
29     #
30     ###############################################################################
31    
32     package Meteor::Message;
33     ###############################################################################
34     # Configuration
35     ###############################################################################
36    
37     use strict;
38    
39     ###############################################################################
40     # Factory methods
41     ###############################################################################
42     sub new {
43     #
44     # Create a new empty instance
45     #
46     my $class=shift;
47    
48     my $obj={};
49    
50     bless($obj,$class);
51     }
52    
53     sub newWithID {
54     #
55     # new instance from new server connection
56     #
57     my $self=shift->new();
58     my $id=shift;
59     my $text=shift || '';
60    
61     $self->{'timestamp'}=time;
62     $self->{'id'}=$id;
63     $self->{'text'}=$text;
64    
65 knops.gerd 25 $::Statistics->{'unique_messages'}++;
66    
67 knops.gerd 11 &::syslog('debug',"New message $id");
68    
69     $self;
70     }
71    
72     ###############################################################################
73     # Instance methods
74     ###############################################################################
75     sub setText {
76     my $self=shift;
77     my $text=shift || '';
78    
79     $self->{'text'}=$text;
80     }
81    
82 knops.gerd 16 sub channelName {
83     shift->{'channel'};
84     }
85    
86     sub setChannelName {
87     my $self=shift;
88     my $channelName=shift || '';
89    
90     $self->{'channel'}=$channelName;
91     }
92    
93 knops.gerd 11 sub text {
94     shift->{'text'};
95     }
96    
97     sub id {
98     shift->{'id'};
99     }
100    
101     sub timestamp {
102     shift->{'timestamp'};
103     }
104    
105     sub message {
106     my $self=shift;
107    
108     my $msg=$::CONF{'MessageTemplate'};
109    
110     $msg=~s/~([^~]*)~/
111     if(!defined($1) || $1 eq '')
112     {
113     '~';
114     }
115     elsif(exists($self->{$1}))
116     {
117     $self->{$1};
118     }
119     else
120     {
121     '';
122     }
123     /gex;
124    
125     $msg;
126     }
127    
128     1;
129 andrew.betts 3 ############################################################################EOF

  ViewVC Help
Powered by ViewVC 1.1.26