-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathCallListener.java
More file actions
99 lines (79 loc) · 2.42 KB
/
CallListener.java
File metadata and controls
99 lines (79 loc) · 2.42 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;
public class CallListener {
public static final int port = 28411;
public String localNick;
public String localAddress;
private boolean busy;
private SocketAddress listenAddress,remoteAdress;
private ServerSocket serverSocket;
public String remoteNick;
public Socket socket;
public CallListener() throws IOException {
this("without name");
}
public CallListener(String localNick) {
this.localNick = localNick;
this.serverSocket = null;
}
public CallListener(String localNick, String localAdress)throws IOException{
try {
serverSocket = new ServerSocket(28411);
} catch (IOException e) {
e.printStackTrace();
}
if (localAdress != null)
serverSocket.bind(new InetSocketAddress(localAdress, 28411));
this.localNick=localNick;
this.listenAddress =new InetSocketAddress(localAdress,port);
}
public Connection getConnection() throws IOException {
socket = serverSocket.accept();
return new Connection(socket, localNick);
}
public SocketAddress getListenAddress() {
return listenAddress;
}
public void setListenAddress(SocketAddress listenAddress) {
this.listenAddress = listenAddress;
}
public String getLocalNick() {
return localNick;
}
public void setLocalNick(String localNick) {
this.localNick = localNick;
}
public String getLocalAddress() {
return localAddress;
}
public void setLocalAddress(String localAddress) {
this.localAddress = localAddress;
}
public SocketAddress getRemoteAdress() {
return remoteAdress;
}
public void setRemoteAdress(SocketAddress remoteAdress) {
this.remoteAdress = remoteAdress;
}
public ServerSocket getServerSocket() {
return serverSocket;
}
public void setServerSocket(ServerSocket serverSocket) {
this.serverSocket = serverSocket;
}
public String getRemoteNick() {
return remoteNick;
}
public void setRemoteNick(String remoteNick) {
this.remoteNick = remoteNick;
}
public boolean isBusy() {
return busy;
}
public void setBusy(boolean busy) {
this.busy = busy;
}
}