-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTCPConnectionInfo.java
More file actions
34 lines (28 loc) · 925 Bytes
/
TCPConnectionInfo.java
File metadata and controls
34 lines (28 loc) · 925 Bytes
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
import java.net.*;
import java.io.*;
public class TCPConnectionInfo {
public Socket connectedToSocket;
public ObjectInputStream in;
public ObjectOutputStream out;
public String associatedPeerId;
public String myPeerID;
TCPConnectionInfo(Socket connectedToSocket, ObjectInputStream in, ObjectOutputStream out, String myPeerID) {
this.connectedToSocket = connectedToSocket;
this.in = in;
this.out = out;
this.myPeerID = myPeerID;
}
public void setAssociatedPeerId(String associatedPeerId) {
this.associatedPeerId = associatedPeerId;
}
public String getAssociatedPeerId() {
return associatedPeerId;
}
public void sendMessage(Message message) throws IOException {
this.out.writeObject(message);
this.out.flush();
}
public boolean isAlive() {
return this.connectedToSocket.isConnected();
}
}