-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkClientV4.java
More file actions
41 lines (33 loc) · 1.05 KB
/
Copy pathNetworkClientV4.java
File metadata and controls
41 lines (33 loc) · 1.05 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
package exception.ex4.exception;
public class NetworkClientV4 {
private final String address;
public boolean connectError;
public boolean sendError;
public NetworkClientV4(String address) {
this.address = address;
}
public void connect() {
if(connectError){
throw new ConnectExceptionV4(address, address + "서버 연결 실패");
}
System.out.println(address + " 서버 연결 성공 ");
}
public void send(String data){
if(sendError){
throw new SendExceptionV4(data, address + "서버에 데이터 전송 실패 : " + data);
// throw new RuntimeException("ex");
}
System.out.println(address + " 서버에 데이터 전송 : " + data);
}
public void disconnect(){
System.out.println(address + " 서버 연결 해제");
}
public void initError(String data){
if(data.contains("error1")){
connectError = true;
}
if(data.contains("error2")){
sendError = true;
}
}
}