Added protocol version check
Former-commit-id: b8a86baa0586c8c87cd92be16789295848c45799
This commit is contained in:
parent
9f9d0e73ee
commit
440cc1ec62
2 changed files with 12 additions and 4 deletions
|
|
@ -49,6 +49,15 @@ public class PCDataSynchronizationClient implements HalDaemon {
|
|||
ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
|
||||
ObjectInputStream in = new ObjectInputStream(s.getInputStream());
|
||||
|
||||
// Check server protocol version
|
||||
int version = in.readInt();
|
||||
if(version != PCDataSynchronizationDaemon.PROTOCOL_VERSION){
|
||||
logger.warning("Protocol version do not match, skipping user. " +
|
||||
"(local v"+PCDataSynchronizationDaemon.PROTOCOL_VERSION+" != remote v"+version+")");
|
||||
out.writeObject(null); // Tell server we are disconnecting
|
||||
continue;
|
||||
}
|
||||
|
||||
// Request peer data
|
||||
out.writeObject(new PeerDataReqDTO());
|
||||
PeerDataRspDTO peerData = (PeerDataRspDTO) in.readObject();
|
||||
|
|
@ -98,9 +107,6 @@ public class PCDataSynchronizationClient implements HalDaemon {
|
|||
logger.fine("Skipped sensor " + sensor.getId());
|
||||
}
|
||||
out.writeObject(null); // Tell server we are disconnecting
|
||||
out.close();
|
||||
in.close();
|
||||
s.close();
|
||||
|
||||
} catch (NoRouteToHostException|UnknownHostException|ConnectException e) {
|
||||
logger.warning("Unable to connect to "+ user.getHostname()+":"+user.getPort() +", "+ e.getMessage());
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import java.util.logging.Logger;
|
|||
|
||||
public class PCDataSynchronizationDaemon extends ThreadedTCPNetworkServer implements HalDaemon {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
public static final int PROTOCOL_VERSION = 2;
|
||||
|
||||
|
||||
public PCDataSynchronizationDaemon() {
|
||||
|
|
@ -71,6 +72,7 @@ public class PCDataSynchronizationDaemon extends ThreadedTCPNetworkServer implem
|
|||
|
||||
try {
|
||||
Object obj = null;
|
||||
out.writeInt(PROTOCOL_VERSION); // send our protocol version to client
|
||||
while((obj = in.readObject()) != null){
|
||||
if(obj instanceof PeerDataReqDTO){
|
||||
logger.fine("Client requesting peer data");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue