-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPPTControllerClient.java
More file actions
64 lines (52 loc) · 2.08 KB
/
PPTControllerClient.java
File metadata and controls
64 lines (52 loc) · 2.08 KB
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
/* This is the client part of the Ppt Controller app/ program.
**
* Created by Saathvik Prasad
**The client creates a socket connection to the server counter part on the main system and
connects to the server using the port number provided. Once the connnection is established the device sends a welcome message to the server and
listens to the activity of it's end to send the same actions to the server.*/
package com.thelogicalcoder.pptcontroller;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.net.InetAddress;
import java.net.Socket;
public class PPTControllerClient {
static Socket socket;
public static void main(String[] args) {
System.out.println("Starting client...");
try {
socket = new Socket("192.168.1.71", 9878);
} catch (IOException e) {
e.printStackTrace();
}
JFrame jFrame = new JFrame("Client");
Button button = new Button("Send");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { //listen to action and send the information to the server.
doThis();
}
});
jFrame.add(button);
jFrame.setSize(400, 600);
jFrame.setVisible(true);
jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
static void doThis() {
try {
OutputStream outputStream = socket.getOutputStream();
PrintWriter printWriter = new PrintWriter(outputStream, true);
// BufferedReader keyRead = new BufferedReader(new InputStreamReader(System.in));
String sendMessage;
//char c = 'y';
//while (true) {
sendMessage = "Hello From the Client : Device Op3";
printWriter.println(sendMessage);
printWriter.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
}