network stuff
This commit is contained in:
parent
5d13869324
commit
3c974a33de
@ -82,6 +82,8 @@ public:
|
|||||||
|
|
||||||
void SendPropertyTree(boost::property_tree::ptree pTree);
|
void SendPropertyTree(boost::property_tree::ptree pTree);
|
||||||
|
|
||||||
|
void DisconnectSlots();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -111,10 +113,11 @@ public:
|
|||||||
|
|
||||||
void StartAccept();
|
void StartAccept();
|
||||||
void HandleAccept(boost::shared_ptr<TConnectedUser> user, const boost::system::error_code& error);
|
void HandleAccept(boost::shared_ptr<TConnectedUser> user, const boost::system::error_code& error);
|
||||||
|
void DeleteUser(boost::shared_ptr<TConnectedUser> user);
|
||||||
|
|
||||||
//Need to generalize this
|
//Need to generalize this
|
||||||
boost::signal<void(boost::shared_ptr<TConnectedUser>)> OnUserAuthorizedSignal;
|
boost::signal<void(boost::shared_ptr<TConnectedUser>)> OnUserAuthorizedSignal;
|
||||||
//boost::signal<void(std::string)> OnUserDisconnectedSignal;
|
boost::signal<void(boost::shared_ptr<TConnectedUser>)> OnUserDisconnectedSignal;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -254,7 +254,20 @@ void TClientSocket::Close()
|
|||||||
|
|
||||||
ClientDataReader->DataReadSignalMap.Clear();
|
ClientDataReader->DataReadSignalMap.Clear();
|
||||||
|
|
||||||
|
std::shared_ptr<TSimpleAuthorization> authorization = boost::get<std::shared_ptr<TSimpleAuthorization>>(Authorization);
|
||||||
|
|
||||||
|
authorization->AuthorizedSignal.disconnect_all_slots();
|
||||||
|
authorization->SaveLoginPasswordSignal.disconnect_all_slots();
|
||||||
|
authorization->ErrorSignal.disconnect_all_slots();
|
||||||
|
|
||||||
|
|
||||||
OnDisconnectedSignal();
|
OnDisconnectedSignal();
|
||||||
|
|
||||||
|
OnAddressNotResolvedSignal.disconnect_all_slots();
|
||||||
|
OnConnectedSignal.disconnect_all_slots();
|
||||||
|
OnAutorizedSignal.disconnect_all_slots();
|
||||||
|
OnDisconnectedSignal.disconnect_all_slots();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,11 +60,14 @@ namespace SE
|
|||||||
|
|
||||||
TConnectedUser::~TConnectedUser()
|
TConnectedUser::~TConnectedUser()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TConnectedUser::HandleAllowed(std::string login)
|
void TConnectedUser::HandleAllowed(std::string login)
|
||||||
{
|
{
|
||||||
UserDataReader = boost::shared_ptr<TDataReader>(new TDataReader(Socket));
|
UserDataReader = boost::shared_ptr<TDataReader>(new TDataReader(Socket));
|
||||||
|
|
||||||
|
UserDataReader->ErrorSignal.connect(boost::bind(&TServerSocket::DeleteUser, &Server, shared_from_this()));
|
||||||
|
|
||||||
Login = login;
|
Login = login;
|
||||||
|
|
||||||
@ -78,6 +81,19 @@ namespace SE
|
|||||||
SE::SendPropertyTree(Server.IoService, Socket, pTree);
|
SE::SendPropertyTree(Server.IoService, Socket, pTree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TConnectedUser::DisconnectSlots()
|
||||||
|
{
|
||||||
|
UserDataReader->DataReadSignalMap.Clear();
|
||||||
|
UserDataReader->ErrorSignal.disconnect_all_slots();
|
||||||
|
|
||||||
|
std::shared_ptr<TSimpleAutorizator> authorizator = boost::get<std::shared_ptr<TSimpleAutorizator>>(Autorizator);
|
||||||
|
|
||||||
|
authorizator->ErrorSignal.disconnect_all_slots();
|
||||||
|
authorizator->AllowedSignal.disconnect_all_slots();
|
||||||
|
authorizator->DeniedSignal.disconnect_all_slots();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -131,8 +147,11 @@ namespace SE
|
|||||||
|
|
||||||
UserArr.push_back(user);
|
UserArr.push_back(user);
|
||||||
|
|
||||||
boost::get<std::shared_ptr<TSimpleAutorizator>>(user->Autorizator)->AllowedSignal.connect(boost::bind(&TConnectedUser::HandleAllowed, user, _1));
|
std::shared_ptr<TSimpleAutorizator> authorizator = boost::get<std::shared_ptr<TSimpleAutorizator>>(user->Autorizator);
|
||||||
|
|
||||||
|
authorizator->AllowedSignal.connect(boost::bind(&TConnectedUser::HandleAllowed, user, _1));
|
||||||
|
authorizator->ErrorSignal.connect(boost::bind(&TServerSocket::DeleteUser, this, user));
|
||||||
|
|
||||||
boost::get<std::shared_ptr<TSimpleAutorizator>>(user->Autorizator)->StartListen();
|
boost::get<std::shared_ptr<TSimpleAutorizator>>(user->Autorizator)->StartListen();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -140,5 +159,16 @@ namespace SE
|
|||||||
StartAccept();
|
StartAccept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TServerSocket::DeleteUser(boost::shared_ptr<TConnectedUser> user)
|
||||||
|
{
|
||||||
|
std::vector<boost::shared_ptr<TConnectedUser>>::iterator i = std::find(UserArr.begin(), UserArr.end(), user);
|
||||||
|
|
||||||
|
user->DisconnectSlots();
|
||||||
|
|
||||||
|
OnUserDisconnectedSignal(user);
|
||||||
|
|
||||||
|
UserArr.erase(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} //namspace SE
|
} //namspace SE
|
Loading…
Reference in New Issue
Block a user