/[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 50 - (hide annotations)
Wed Feb 27 13:55:35 2008 UTC (16 years, 1 month ago) by andrew.betts
Original Path: googlecode.com/svn/trunk/Meteor/Message.pm
File size: 2841 byte(s)
Added crossdomain.xml for flash clients
Incremented version number
Moved 'new message' debug notice to more useful location
Moved default for ChannelInfoTemplate to correct position alphabetically in code
Set simpler default HeaderTemplate
Added LogTimeFormat
Updated description of PingInterval, Persist
Corrected misspelling of Parameter
Reformatted debug output for config initialisation
Added recognition of null byte in config
Fixed problem with mode recognition
Fixed resuming from given message ID
Fixed sending of message backlog
Fixed Shlemiels
Logged connection duration on leavechannel
Fixed name support in channelinfotemplate
Added logging of reasons for connection closes
Abbreviated log output
Fixed tracking of subscriber IDs
Added logging of user agent
Fixed incorrect key for MessageTemplate in Subscriber.pm
Add some additional code comments
Fixed incorrect closure of new connection if previous connection close was waiting on write buffer

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 andrew.betts 50
67 knops.gerd 11 $self;
68     }
69    
70     ###############################################################################
71     # Instance methods
72     ###############################################################################
73     sub setText {
74     my $self=shift;
75     my $text=shift || '';
76    
77     $self->{'text'}=$text;
78     }
79    
80 knops.gerd 16 sub channelName {
81     shift->{'channel'};
82     }
83    
84     sub setChannelName {
85     my $self=shift;
86     my $channelName=shift || '';
87    
88     $self->{'channel'}=$channelName;
89     }
90    
91 knops.gerd 11 sub text {
92     shift->{'text'};
93     }
94    
95     sub id {
96     shift->{'id'};
97     }
98    
99     sub timestamp {
100     shift->{'timestamp'};
101     }
102    
103     sub message {
104 knops.gerd 45
105     shift->messageWithTemplate($::CONF{'MessageTemplate'});
106     }
107    
108     sub messageWithTemplate {
109 knops.gerd 11 my $self=shift;
110 knops.gerd 45 my $msg=shift;
111 knops.gerd 11
112     $msg=~s/~([^~]*)~/
113     if(!defined($1) || $1 eq '')
114     {
115     '~';
116     }
117     elsif(exists($self->{$1}))
118     {
119     $self->{$1};
120     }
121     else
122     {
123     '';
124     }
125     /gex;
126    
127     $msg;
128     }
129    
130     1;
131 andrew.betts 3 ############################################################################EOF

  ViewVC Help
Powered by ViewVC 1.1.26