6 use Data::Dump qw(dump);
8 my $sock = IO::Socket::INET->new(
10 # LocalAddr => 'localhost',
16 warn "listen on ", dump $sock->sockaddr, $sock->sockport;
20 read $client, my $len, 2;
21 $len = unpack( 'n', $len );
22 read $client, my $utf, $len;
23 warn "## readUTF $len [$utf]";
27 # from PRemoteDroid Protocol/src/org/pierre/remotedroid/protocol/action/PRemoteDroidAction.java
28 use constant MOUSE_MOVE => 0;
29 use constant MOUSE_CLICK => 1;
30 use constant MOUSE_WHEEL => 2;
31 use constant KEYBOARD => 3;
32 use constant AUTHENTIFICATION => 4;
33 use constant AUTHENTIFICATION_RESPONSE => 5;
34 use constant SCREEN_CAPTURE_REQUEST => 6;
35 use constant SCREEN_CAPTURE_RESPONSE => 7;
36 use constant FILE_EXPLORE_REQUEST => 8;
37 use constant FILE_EXPLORE_RESPONSE => 9;
39 while ( my $client = $sock->accept() ) {
41 warn "connect from ", dump $client->peeraddr, $client->peerport;
43 while ( read $client, my $command, 1 ) {
44 $command = ord $command;
45 warn "# command: $command\n";
46 if ( $command == MOUSE_MOVE ) {
47 read $client, my $move, 4;
48 my ( $x, $y ) = unpack 's>s>', $move; # big-endian 16 bit
50 } elsif ( $command == MOUSE_CLICK ) {
51 read $client, my $b, 2;
52 my ( $button, $state ) = unpack 'cc', $b;
53 warn "MOUSE_CLICK $button $state\n";
54 } elsif ( $command == MOUSE_WHEEL ) {
55 read $client, my $amount, 1;
56 $amount = unpack 'c', $amount;
57 warn "MOUSE_WHEEL $amount\n";
58 } elsif ( $command == AUTHENTIFICATION ) {
59 my $auth = readUTF $client;
60 warn "AUTHENTIFICATION [$auth]\n";
61 print $client pack 'cc', AUTHENTIFICATION_RESPONSE, 1; # FIXME anything goes
67 warn "client disconnected\n";