Schrift
[thread]6429[/thread]

client abfrage: abfrage einer message und auswertung

Leser: 1


<< >> 3 Einträge, 1 Seite
bartman
 2004-07-24 19:32
#84907 #84907
User since
2004-07-24
1 Artikel
BenutzerIn
[default_avatar]
Hi,
ich möchte einen client schreiben, der vom server LCDd eingehende Messages auswertet und ein programm startet. das ganze unter linux.

Hat jemand eine Idee warum mein Programm nicht funktioniert und die Message nicht richtig ausgewertet wird?

Programm:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/perl -w

use IO::Socket;
use Fcntl;
use strict;
use LCDd;




# Connect to the server...
my ($remote) = IO::Socket::INET->new(
                 Proto     => "tcp",
                 PeerAddr  => "localhost",
                 PeerPort  => "13666")
|| die "Cannot connect to LCDproc port\n";

# Make sure our messages get there right away
$remote->autoflush(1);

# Give server plenty of time to notice us...
sleep 1;

print $remote "hello\n";


# Turn off blocking mode...
fcntl($remote, F_SETFL, O_NONBLOCK);




# Set up some screen widgets...
print $remote "client_set name {ronny}\n";
print $remote "screen_add screen\n";
print $remote "screen_set screen -name {screen}\n";
print $remote "screen_set screen -heartbeat {off}\n"; #don't work, why???
print $remote "menu_add_item \"\" mymenu menu {jukebox}\n";

print $remote "menu_add_item mymenu sub_techno menu {Techno}\n";



print $remote "menu_add_item sub_techno action_favourite_techno action {Favourite} \n";
print $remote "menu_add_item sub_techno action_all_techno action {all}\n";


print $remote "menu_set_item sub_techno action_favourite_techno -menu_result {close}\n";
print $remote "menu_set_item sub_techno action_all_techno -menu_result {close}\n";








sub handleinput {
   my $input = @_;
   if ($input =~ /^menuevent (.*?) (.*)$/) {
       menuevent($1, $2);
   }
   return;
}

sub menuevent
{

   #menustates
  my ($event, $id) = @_;

   #print "Event: $event, id: $id\n";
   if ($id eq "action_favourite_techno")
   {
       #test1
system("xmms");
   }
   elsif ($id eq "action_all_techno")
   {
system("yast");
   }
    else
   {
    system("xmms");
       print "huh? Unknown menuid: $id , and event: $event.\n";
   }
}



while(1)
{

print $remote "menu_goto mymenu\n";

sleep 1;

handleinput();


}

close ($remote) || die "close: $!";


#EOF



Denke mal das es am Polling liegt?!

Danke Ronny







exit;


EDIT: CODE-Tags spendiert, -Dubu-\n\n

<!--EDIT|Dubu|1090765473-->
Dubu
 2004-07-25 18:22
#84908 #84908
User since
2003-08-04
2145 Artikel
ModeratorIn + EditorIn

user image
Code: (dl )
1
2
3
sub handleinput {
my $input = @_;
...

Entweder
my ($input) = @_;
oder
my $input = shift;
oder
my $input = $_[0];

Deine Methode ergibt in $input nur die Anzahl der Elemente im Array @_.
Crian
 2004-07-26 01:45
#84909 #84909
User since
2003-08-04
5866 Artikel
ModeratorIn
[Homepage]
user image
Willkommen bartman :)
s--Pevna-;s.([a-z]).chr((ord($1)-84)%26+97).gee; s^([A-Z])^chr((ord($1)-52)%26+65)^gee;print;

use strict; use warnings; Link zu meiner Perlseite
<< >> 3 Einträge, 1 Seite



View all threads created 2004-07-24 19:32.