MCPcopy Create free account
hub / github.com/ddnet/ddnet / SendDeleteIfRegistered

Method SendDeleteIfRegistered

src/engine/server/register.cpp:335–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333}
334
335void CRegister::CProtocol::SendDeleteIfRegistered(bool Shutdown)
336{
337 {
338 const CLockScope LockScope(m_pShared->m_Lock);
339 const bool ShouldSendDelete = m_pShared->m_LatestResponseStatus == STATUS_OK;
340 m_pShared->m_LatestResponseStatus = STATUS_NONE;
341 if(!ShouldSendDelete)
342 return;
343 }
344
345 char aAddress[64];
346 str_format(aAddress, sizeof(aAddress), "%sconnecting-address.invalid:%d", ProtocolToScheme(m_Protocol), m_pParent->m_ServerPort);
347
348 char aSecret[UUID_MAXSTRSIZE];
349 FormatUuid(m_pParent->m_Secret, aSecret, sizeof(aSecret));
350
351 std::shared_ptr<CHttpRequest> pDelete = HttpPost(m_pParent->m_pConfig->m_SvRegisterUrl, (const unsigned char *)"", 0);
352 pDelete->HeaderString("Action", "delete");
353 pDelete->HeaderString("Address", aAddress);
354 pDelete->HeaderString("Secret", aSecret);
355 for(int i = 0; i < m_pParent->m_NumExtraHeaders; i++)
356 {
357 pDelete->Header(m_pParent->m_aaExtraHeaders[i]);
358 }
359 pDelete->LogProgress(HTTPLOG::FAILURE);
360 pDelete->IpResolve(ProtocolToIpresolve(m_Protocol));
361 if(Shutdown)
362 {
363 // On shutdown, wait at most 1 second for the delete requests.
364 pDelete->Timeout(CTimeout{1000, 1000, 0, 0});
365 }
366 log_info(ProtocolToSystem(m_Protocol), "deleting...");
367 m_pParent->m_pHttp->Run(pDelete);
368}
369
370CRegister::CProtocol::CProtocol(CRegister *pParent, int Protocol) :
371 m_pParent(pParent),

Callers 2

OnConfigChangeMethod · 0.80
OnShutdownMethod · 0.80

Calls 9

str_formatFunction · 0.85
FormatUuidFunction · 0.85
HttpPostFunction · 0.85
HeaderStringMethod · 0.80
HeaderMethod · 0.80
LogProgressMethod · 0.80
IpResolveMethod · 0.80
TimeoutMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected