Created
August 10, 2018 19:48
-
-
Save sangfansh/eadaa5c6e6d10fe43e3a562c8efd7f4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector<string> VerificationManager::incomingHandler(string v, int type) { | |
vector<string> res; | |
if (!v.empty()) { | |
string s; | |
bool ret; | |
switch (type) { | |
case RA_MSG0: { | |
Messages::MessageMsg0 msg0; | |
ret = msg0.ParseFromString(v); | |
if (ret && (msg0.type() == RA_MSG0)) { | |
s = this->handleMSG0(msg0); | |
res.push_back(to_string(RA_MSG0)); | |
} | |
} | |
break; | |
case RA_MSG1: { | |
Messages::MessageMSG1 msg1; | |
ret = msg1.ParseFromString(v); | |
if (ret && (msg1.type() == RA_MSG1)) { | |
s = this->handleMSG1(msg1); | |
res.push_back(to_string(RA_MSG2)); | |
} | |
} | |
break; | |
case RA_MSG3: { | |
Messages::MessageMSG3 msg3; | |
ret = msg3.ParseFromString(v); | |
if (ret && (msg3.type() == RA_MSG3)) { | |
s = this->handleMSG3(msg3); | |
res.push_back(to_string(RA_ATT_RESULT)); | |
} | |
} | |
break; | |
case RA_APP_ATT_OK: { | |
Messages::SecretMessage sec_msg; | |
ret = sec_msg.ParseFromString(v); | |
if (ret) { | |
if (sec_msg.type() == RA_APP_ATT_OK) { | |
this->handleAppAttOk(); | |
} | |
} | |
} | |
break; | |
default: | |
Log("Unknown type: %d", type, log::error); | |
break; | |
} | |
res.push_back(s); | |
} else { //after handshake | |
res.push_back(to_string(RA_VERIFICATION)); | |
res.push_back(this->prepareVerificationRequest()); | |
} | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment