forked from manalbctt/remoteDesktopServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RecieveEvents.java
45 lines (42 loc) · 1.33 KB
/
RecieveEvents.java
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
import java.awt.*;
import java.io.IOException;
import java.net.Socket;
import java.util.Scanner;
public class RecieveEvents extends Thread {
Socket socket = null;
Robot robot = null;
boolean continueLoop = true;
public RecieveEvents(Socket socket, Robot robot) {
this.socket = socket;
this.robot = robot;
start();
}
public void run() {
Scanner scanner = null;
try {
scanner = new Scanner(socket.getInputStream());
while (continueLoop) {
int command = scanner.nextInt();
switch (command) {
case -1:
robot.mousePress(scanner.nextInt());
break;
case -2:
robot.mouseRelease(scanner.nextInt());
break;
case -3:
robot.keyPress(scanner.nextInt());
break;
case -4:
robot.keyRelease(scanner.nextInt());
break;
case -5:
robot.mouseMove(scanner.nextInt(), scanner.nextInt());
break;
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}