Page 848 - 3-2
P. 848
SenserThread.gpio26.low();
if(str.substring(2).equals("senser")) SenserThread.senser();
}
else sendAll(str);
} catch (Exception e) {
System.out.println(e.toString() + "din");
acc=0;
}
}
}
static void sendMsg(String msg) { // 서버에 데이터를 보냄
try {
dout.writeUTF(my +"_"+ msg);
System.out.println(" 서버에 보냄: " + my +"_"+ msg);
} catch(Exception e) {
System.out.println(e.toString()+ "12");
acc=0;
}
}
public void sendAll(String msg) {
// 접속되어있는 클라이언트들에게 받은 데이터를 보냄
for (int i = 0; i < v.size(); i++) {
ServerThread client = (ServerThread)v.get(i);
System.out.println(" 클라이언트에 보냄: " + msg);
client.sendMsg(msg); // 클라이언트에 메세지 보냄
}
}
public static void main (String args[]) {
jframe.setVisible(true);
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe.setBounds(100, 100, 574, 226);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
jframe.setContentPane(contentPane);
contentPane.setLayout(null);
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
sendMsg("1");
- 848 -