mirror of
https://gitee.com/TarsCloud/TarsCpp.git
synced 2024-12-22 22:16:38 +08:00
Transceiver add finishInvoke for auth
This commit is contained in:
parent
5229509b66
commit
2eaa72a378
@ -489,29 +489,29 @@ void AdapterProxy::finishInvoke(shared_ptr<ResponsePacket> & rsp)
|
|||||||
TLOGTARS("[TARS][AdapterProxy::finishInvoke(ResponsePacket) objname:" << _objectProxy->name() << ",desc:" << _endpoint.desc()
|
TLOGTARS("[TARS][AdapterProxy::finishInvoke(ResponsePacket) objname:" << _objectProxy->name() << ",desc:" << _endpoint.desc()
|
||||||
<< ",id:" << rsp->iRequestId << endl);
|
<< ",id:" << rsp->iRequestId << endl);
|
||||||
|
|
||||||
if (_trans->getAuthState() != AUTH_SUCC)
|
// if (_trans->getAuthState() != AUTH_SUCC)
|
||||||
{
|
// {
|
||||||
std::string ret(rsp->sBuffer.begin(), rsp->sBuffer.end());
|
// std::string ret(rsp->sBuffer.begin(), rsp->sBuffer.end());
|
||||||
tars::AUTH_STATE tmp = AUTH_SUCC;
|
// tars::AUTH_STATE tmp = AUTH_SUCC;
|
||||||
tars::stoe(ret, tmp);
|
// tars::stoe(ret, tmp);
|
||||||
int newstate = tmp;
|
// int newstate = tmp;
|
||||||
|
//
|
||||||
TLOGTARS("[TARS]AdapterProxy::finishInvoke from state " << _trans->getAuthState() << " to " << newstate << endl);
|
// TLOGTARS("[TARS]AdapterProxy::finishInvoke from state " << _trans->getAuthState() << " to " << newstate << endl);
|
||||||
_trans->setAuthState(newstate);
|
// _trans->setAuthState(newstate);
|
||||||
|
//
|
||||||
if (newstate == AUTH_SUCC)
|
// if (newstate == AUTH_SUCC)
|
||||||
{
|
// {
|
||||||
// flush old buffered msg when auth is not complete
|
// // flush old buffered msg when auth is not complete
|
||||||
doInvoke();
|
// doInvoke();
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
TLOGERROR("newstate is " << newstate << ", error close!\n");
|
// TLOGERROR("newstate is " << newstate << ", error close!\n");
|
||||||
_trans->close();
|
// _trans->close();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
ReqMessage * msg = NULL;
|
ReqMessage * msg = NULL;
|
||||||
|
|
||||||
|
@ -161,13 +161,13 @@ void Transceiver::setConnected()
|
|||||||
_adapterProxy->setConTimeout(false);
|
_adapterProxy->setConTimeout(false);
|
||||||
_adapterProxy->addConnExc(false);
|
_adapterProxy->addConnExc(false);
|
||||||
|
|
||||||
_onConnect();
|
onConnect();
|
||||||
|
|
||||||
|
|
||||||
TLOGTARS("[TARS][tcp setConnected, " << _adapterProxy->getObjProxy()->name() << ",fd:" << _fd << "]" << endl);
|
TLOGTARS("[TARS][tcp setConnected, " << _adapterProxy->getObjProxy()->name() << ",fd:" << _fd << "]" << endl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transceiver::_onConnect()
|
void Transceiver::onConnect()
|
||||||
{
|
{
|
||||||
#if TARS_SSL
|
#if TARS_SSL
|
||||||
if (isSSL())
|
if (isSSL())
|
||||||
@ -204,14 +204,14 @@ void Transceiver::_onConnect()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_doAuthReq();
|
doAuthReq();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transceiver::_doAuthReq()
|
void Transceiver::doAuthReq()
|
||||||
{
|
{
|
||||||
ObjectProxy* obj = _adapterProxy->getObjProxy();
|
ObjectProxy* obj = _adapterProxy->getObjProxy();
|
||||||
|
|
||||||
TLOGTARS("[TARS][_onConnect:" << obj->name() << " auth type is " << _adapterProxy->endpoint().authType() << endl);
|
TLOGTARS("[TARS][onConnect:" << obj->name() << " auth type is " << _adapterProxy->endpoint().authType() << endl);
|
||||||
|
|
||||||
if (_adapterProxy->endpoint().authType() == AUTH_TYPENONE)
|
if (_adapterProxy->endpoint().authType() == AUTH_TYPENONE)
|
||||||
{
|
{
|
||||||
@ -229,6 +229,35 @@ void Transceiver::_doAuthReq()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Transceiver::finishInvoke(shared_ptr<ResponsePacket> &rsp)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (_authState != AUTH_SUCC)
|
||||||
|
{
|
||||||
|
std::string ret(rsp->sBuffer.begin(), rsp->sBuffer.end());
|
||||||
|
tars::AUTH_STATE tmp = AUTH_SUCC;
|
||||||
|
tars::stoe(ret, tmp);
|
||||||
|
int newstate = tmp;
|
||||||
|
|
||||||
|
TLOGTARS("[TARS]AdapterProxy::finishInvoke from state " << _authState << " to " << newstate << endl);
|
||||||
|
setAuthState(newstate);
|
||||||
|
|
||||||
|
if (newstate == AUTH_SUCC)
|
||||||
|
{
|
||||||
|
// flush old buffered msg when auth is not complete
|
||||||
|
_adapterProxy->doInvoke();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TLOGERROR("newstate is " << newstate << ", error close!\n");
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_adapterProxy->finishInvoke(rsp);
|
||||||
|
}
|
||||||
|
|
||||||
bool Transceiver::sendAuthData(const BasicAuthInfo& info)
|
bool Transceiver::sendAuthData(const BasicAuthInfo& info)
|
||||||
{
|
{
|
||||||
assert (_authState != AUTH_SUCC);
|
assert (_authState != AUTH_SUCC);
|
||||||
@ -474,7 +503,7 @@ int TcpTransceiver::doResponse()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (ret == TC_NetWorkBuffer::PACKET_FULL) {
|
else if (ret == TC_NetWorkBuffer::PACKET_FULL) {
|
||||||
_adapterProxy->finishInvoke(rsp);
|
finishInvoke(rsp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
break;
|
break;
|
||||||
@ -585,7 +614,7 @@ int TcpTransceiver::doResponse()
|
|||||||
// return 0;
|
// return 0;
|
||||||
|
|
||||||
// if (preNotHandshake)
|
// if (preNotHandshake)
|
||||||
// _doAuthReq();
|
// doAuthReq();
|
||||||
|
|
||||||
// std::string* plainBuf = _openssl->RecvBuffer();
|
// std::string* plainBuf = _openssl->RecvBuffer();
|
||||||
// data = plainBuf->data();
|
// data = plainBuf->data();
|
||||||
@ -817,7 +846,7 @@ int UdpTransceiver::doResponse()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_adapterProxy->finishInvoke(rsp);
|
finishInvoke(rsp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (exception &ex)
|
catch (exception &ex)
|
||||||
|
@ -210,6 +210,8 @@ public:
|
|||||||
_connStatus = eUnconnected;
|
_connStatus = eUnconnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void finishInvoke(shared_ptr<ResponsePacket> &rsp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置鉴权状态
|
* 设置鉴权状态
|
||||||
*/
|
*/
|
||||||
@ -232,12 +234,12 @@ protected:
|
|||||||
/**
|
/**
|
||||||
** 物理连接成功回调
|
** 物理连接成功回调
|
||||||
**/
|
**/
|
||||||
void _onConnect();
|
void onConnect();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** 鉴权初始化请求
|
** 鉴权初始化请求
|
||||||
**/
|
**/
|
||||||
void _doAuthReq();
|
void doAuthReq();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* AdapterProxy
|
* AdapterProxy
|
||||||
|
Loading…
Reference in New Issue
Block a user