mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-12-20 08:27:11 +01:00
issiauskinau kad checksum yra nahuj reikalingas ir kad onConnect turejo buti uzkomentuotas. Reikia issiaiskinti kodel luzta onLogin clientas. Kitus failus reikia perziureti ir isvalyti siuksles
This commit is contained in:
@@ -56,7 +56,8 @@ void ServiceManager::stop()
|
||||
for (auto& servicePortIt : acceptors) {
|
||||
try {
|
||||
io_service.post(std::bind(&ServicePort::onStopServer, servicePortIt.second));
|
||||
} catch (boost::system::system_error& e) {
|
||||
}
|
||||
catch (boost::system::system_error& e) {
|
||||
std::cout << "[ServiceManager::stop] Network Error: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
@@ -114,25 +115,28 @@ void ServicePort::onAccept(Connection_ptr connection, const boost::system::error
|
||||
Service_ptr service = services.front();
|
||||
if (service->is_single_socket()) {
|
||||
connection->accept(service->make_protocol(connection));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
connection->accept();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
connection->close(Connection::FORCE_CLOSE);
|
||||
}
|
||||
|
||||
accept();
|
||||
} else if (error != boost::asio::error::operation_aborted) {
|
||||
}
|
||||
else if (error != boost::asio::error::operation_aborted) {
|
||||
if (!pendingStart) {
|
||||
close();
|
||||
pendingStart = true;
|
||||
g_scheduler.addEvent(createSchedulerTask(15000,
|
||||
std::bind(&ServicePort::openAcceptor, std::weak_ptr<ServicePort>(shared_from_this()), serverPort)));
|
||||
std::bind(&ServicePort::openAcceptor, std::weak_ptr<ServicePort>(shared_from_this()), serverPort)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Protocol_ptr ServicePort::make_protocol(bool checksummed, NetworkMessage& msg, const Connection_ptr& connection) const
|
||||
Protocol_ptr ServicePort::make_protocol(NetworkMessage& msg, const Connection_ptr& connection) const
|
||||
{
|
||||
uint8_t protocolID = msg.getByte();
|
||||
for (auto& service : services) {
|
||||
@@ -140,9 +144,7 @@ Protocol_ptr ServicePort::make_protocol(bool checksummed, NetworkMessage& msg, c
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((checksummed && service->is_checksummed()) || !service->is_checksummed()) {
|
||||
return service->make_protocol(connection);
|
||||
}
|
||||
return service->make_protocol(connection);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -169,21 +171,23 @@ void ServicePort::open(uint16_t port)
|
||||
try {
|
||||
if (g_config.getBoolean(ConfigManager::BIND_ONLY_GLOBAL_ADDRESS)) {
|
||||
acceptor.reset(new boost::asio::ip::tcp::acceptor(io_service, boost::asio::ip::tcp::endpoint(
|
||||
boost::asio::ip::address(boost::asio::ip::address_v4::from_string(g_config.getString(ConfigManager::IP))), serverPort)));
|
||||
} else {
|
||||
boost::asio::ip::address(boost::asio::ip::address_v4::from_string(g_config.getString(ConfigManager::IP))), serverPort)));
|
||||
}
|
||||
else {
|
||||
acceptor.reset(new boost::asio::ip::tcp::acceptor(io_service, boost::asio::ip::tcp::endpoint(
|
||||
boost::asio::ip::address(boost::asio::ip::address_v4(INADDR_ANY)), serverPort)));
|
||||
boost::asio::ip::address(boost::asio::ip::address_v4(INADDR_ANY)), serverPort)));
|
||||
}
|
||||
|
||||
acceptor->set_option(boost::asio::ip::tcp::no_delay(true));
|
||||
|
||||
accept();
|
||||
} catch (boost::system::system_error& e) {
|
||||
}
|
||||
catch (boost::system::system_error& e) {
|
||||
std::cout << "[ServicePort::open] Error: " << e.what() << std::endl;
|
||||
|
||||
pendingStart = true;
|
||||
g_scheduler.addEvent(createSchedulerTask(15000,
|
||||
std::bind(&ServicePort::openAcceptor, std::weak_ptr<ServicePort>(shared_from_this()), port)));
|
||||
std::bind(&ServicePort::openAcceptor, std::weak_ptr<ServicePort>(shared_from_this()), port)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +201,7 @@ void ServicePort::close()
|
||||
|
||||
bool ServicePort::add_service(const Service_ptr& new_svc)
|
||||
{
|
||||
if (std::any_of(services.begin(), services.end(), [](const Service_ptr& svc) {return svc->is_single_socket();})) {
|
||||
if (std::any_of(services.begin(), services.end(), [](const Service_ptr& svc) {return svc->is_single_socket(); })) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user