1.修改ICommunicator
ICommunicator增加:
class ICommunicator {
public:
virtual void CloseAllConn() = 0; ///< 关闭所有连接
};
2.修改CControl
CControl增加:
class CControl {
public:
void CloseAllConn(); ///< 关闭所有连接
};
//---------------------------------------------------------------------------
/// 为提高登录时取消响应性增加的函数:目前只关闭TCP连接
///< 问题的症结在:Login窗口无法获取正在执行的连接
void CControl::CloseAllConn() {
tagConnMap::iterator iter = m_TCPConnPool.m_ConnMap.begin();
while(iter!=m_TCPConnPool.m_ConnMap.end()) {
tagConnInfo *conn_info = *iter;
if (conn_info->conn_) {
SOCKET handle = conn_info->conn_->GetSocket();
if (handle!=INVALID_SOCKET)
closesocket(handle);
}
iter++;
}
}
3.修改CPluginControl
CPluginControl增加:
class CSDK_API CPluginControl : public CBaseControl {
public:
void CloseAllConn(); ///< 关闭所有连接
};
//---------------------------------------------------------------------------
void CPluginControl::CloseAllConn() {
communicator_->CloseAllConn();
}
4.修改TLoginForm
//---------------------------------------------------------------------------
void __fastcall TLoginForm::OnCancelButtonClick(TObject *Sender)
{
bNeedAutoRelogin = false;
iTryReloginTimes = 0;
iAutoReloginWaitedTime = 0;
if(!IsLogining || !Can_Cancel || IsCanceling)
{
return;
}
///< 为了快速取消采用直接关闭所有连接的做法:实际上框架管理的通信连接池,此时只有一个与服务器的连接
controller->CloseAllConn();
IsCanceling = true;
lbShowInfo->Caption = "正在取消.";
}
客户端提高登录过程取消操作的响应性的修改
最新推荐文章于 2024-06-05 21:01:31 发布