PICloud change protocol > server_uuid
This commit is contained in:
@@ -28,7 +28,7 @@ const char hash_def_key[] = "_picrypt_";
|
||||
|
||||
|
||||
PICloud::TCP::Header::Header() {
|
||||
version = Version_1;
|
||||
version = Version_2;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,15 +42,20 @@ void PICloud::TCP::setRole(PICloud::TCP::Role r) {
|
||||
|
||||
|
||||
void PICloud::TCP::setServerName(const PIString & server_name) {
|
||||
sname = server_name;
|
||||
suuid = PICrypt::hash(server_name);
|
||||
}
|
||||
|
||||
|
||||
void PICloud::TCP::sendStart() {
|
||||
//piCout << "sendStart";
|
||||
if (suuid.size() != PICrypt::sizeHash()) {
|
||||
piCout << "PICloud ERROR, server not set, invoke setServerName first";
|
||||
return;
|
||||
}
|
||||
header.type = PICloud::TCP::Connect;
|
||||
PIByteArray ba;
|
||||
ba << header << sname;
|
||||
ba << header;
|
||||
ba.append(suuid);
|
||||
streampacker->send(ba);
|
||||
}
|
||||
|
||||
@@ -100,7 +105,7 @@ PIPair<PICloud::TCP::Type, PICloud::TCP::Role> PICloud::TCP::parseHeader(PIByteA
|
||||
PICloud::TCP::Header hdr;
|
||||
ba >> hdr;
|
||||
if (hdr.version != header.version) {
|
||||
piCout << "[PICloud]" << "invalid TCP version!";
|
||||
piCout << "[PICloud]" << "invalid PICloud::TCP version!";
|
||||
return ret;
|
||||
}
|
||||
ret.first = (Type)hdr.type;
|
||||
@@ -128,10 +133,13 @@ PIPair<uint, PIByteArray> PICloud::TCP::parseDataServer(PIByteArray & ba) {
|
||||
}
|
||||
|
||||
|
||||
PIString PICloud::TCP::parseConnect_d(PIByteArray & ba) {
|
||||
PIString ret;
|
||||
ba >> ret;
|
||||
return ret;
|
||||
PIByteArray PICloud::TCP::parseConnect_d(PIByteArray & ba) {
|
||||
if (ba.size() != PICrypt::sizeHash()) {
|
||||
piCout << "PICloud ERROR, invalid server uuid";
|
||||
return PIByteArray();
|
||||
} else {
|
||||
return ba;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user