ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/MessageDistributor.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/MessageDistributor.pm (file contents):
Revision 1.8 by root, Sat Apr 3 02:58:25 2010 UTC vs.
Revision 1.9 by root, Wed Jan 4 11:23:23 2012 UTC

3use common::sense; 3use common::sense;
4 4
5sub new { 5sub new {
6 my $this = shift; 6 my $this = shift;
7 my $class = ref($this) || $this; 7 my $class = ref($this) || $this;
8 my $self = { @_ }; 8 my $self = bless { @_ }, $class;
9 bless $self, $class;
10 9
11 $self->{dockbar}->add_dock ( 10 $self->{dockbar}->add_dock (
12 $self->{log} = DC::UI::ChatView->new ( 11 $self->{log} = DC::UI::ChatView->new (
13 expand => 1, 12 expand => 1,
14 can_close => 0, 13 can_close => 0,
36 35
37# adding channel 36# adding channel
38sub add_channel { 37sub add_channel {
39 my ($self, $chaninfo) = @_; 38 my ($self, $chaninfo) = @_;
40 39
41 $self->{info}->{$chaninfo->{id}} = $chaninfo; 40 $self->{info}{$chaninfo->{id}} = $chaninfo;
42 $self->touch_channel ($chaninfo->{id}); 41 $self->touch_channel ($chaninfo->{id});
43} 42}
44 43
45# set max paragraphs 44# set max paragraphs
46sub set_max_par { 45sub set_max_par {
62# push message in 61# push message in
63sub message { 62sub message {
64 my ($self, $para) = @_; 63 my ($self, $para) = @_;
65 my $id = $para->{type}; 64 my $id = $para->{type};
66 65
67 if (exists $self->{info}->{$id}) { 66 if (exists $self->{info}{$id}) {
68 unless (exists $self->{chatview}->{$id}) { 67 unless (exists $self->{chatview}->{$id}) {
69 $self->touch_channel ($id); 68 $self->touch_channel ($id);
70 } 69 }
71 70
72 my $cv = $self->{chatview}->{$id}; 71 my $cv = $self->{chatview}{$id};
73 72
74 unless ($cv) { 73 unless ($cv) {
75 warn "message couldn't be delivered to chatview with " 74 warn "message couldn't be delivered to chatview with "
76 ."id '$id', sending it to main log."; 75 ."id '$id', sending it to main log.";
77 $self->{log}->message ($para); 76 $self->{log}->message ($para);
86} 85}
87 86
88sub touch_channel { 87sub touch_channel {
89 my ($self, $id) = @_; 88 my ($self, $id) = @_;
90 89
91 if (exists $self->{chatview}->{$id}) { 90 if (exists $self->{chatview}{$id}) {
92 $self->update_chat ($id); 91 $self->update_chat ($id);
93 } else { 92 } else {
94 $self->init_chat ($id); 93 $self->init_chat ($id);
95 } 94 }
96} 95}
97 96
98sub update_chat { 97sub update_chat {
99 my ($self, $id) = @_; 98 my ($self, $id) = @_;
100 99
101 $self->{chatview}->{$id}->update_info ($self->{info}->{$id}); 100 $self->{chatview}{$id}->update_info ($self->{info}->{$id});
102} 101}
103 102
104sub init_chat { 103sub init_chat {
105 my ($self, $id) = @_; 104 my ($self, $id) = @_;
106 105
107 my $chaninfo = $self->{info}->{$id}; 106 my $chaninfo = $self->{info}{$id};
108 my $dock = $self->{chatview}->{$id} = 107 my $dock = $self->{chatview}{$id} =
109 DC::UI::ChatView->new ( 108 DC::UI::ChatView->new (
110 expand => 1, 109 expand => 1,
111 info => $chaninfo, 110 info => $chaninfo,
112 ); 111 );
113 $dock->connect (close_dock => sub { 112 $dock->connect (close_dock => sub {
114 delete $self->{chatview}->{$id}; 113 delete $self->{chatview}{$id};
115 0 114 0
116 }); 115 });
117 $self->{dockbar}->add_dock ($dock); 116 $self->{dockbar}->add_dock ($dock);
118} 117}
119 118

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines