OpenClonk
C4Network2ClientList Class Reference

#include <C4Network2Client.h>

Collaboration diagram for C4Network2ClientList:
[legend]

Public Member Functions

 C4Network2ClientList (C4Network2IO *pIO)
 
 ~C4Network2ClientList ()
 
C4Network2ClientGetClientByID (int32_t iID) const
 
C4Network2ClientGetNextClientAfterID (int32_t iSmallerClientID) const
 
C4Network2ClientGetClient (const char *szName) const
 
C4Network2ClientGetClient (const C4ClientCore &CCore, int32_t iMaxDiffLevel=C4ClientCoreDL_IDMatch)
 
C4Network2ClientGetClient (C4Network2IOConnection *pConn) const
 
C4Network2ClientGetLocal () const
 
C4Network2ClientGetHost ()
 
C4Network2ClientGetNextClient (C4Network2Client *pClient)
 
unsigned int Count ()
 
void Init (C4ClientList *pClientList, bool fHost)
 
C4Network2ClientRegClient (C4Client *pClient)
 
void DeleteClient (C4Network2Client *pClient)
 
void Clear ()
 
bool BroadcastMsgToConnClients (const C4NetIOPacket &rPkt)
 
bool BroadcastMsgToClients (const C4NetIOPacket &rPkt)
 
bool SendMsgToHost (C4NetIOPacket rPkt)
 
bool SendMsgToClient (int32_t iClient, C4NetIOPacket &&rPkt)
 
void HandlePacket (char cStatus, const C4PacketBase *pBasePkt, C4Network2IOConnection *pConn)
 
void SendAddresses (C4Network2IOConnection *pConn)
 
void DoConnectAttempts ()
 
void ResetReady ()
 
bool AllClientsReady () const
 
void UpdateClientActivity ()
 

Protected Attributes

C4Network2IOpIO
 
C4Network2ClientpFirst
 
C4Network2ClientpLocal
 
C4ClientListpClientList
 
bool fHost
 

Detailed Description

Definition at line 143 of file C4Network2Client.h.

Constructor & Destructor Documentation

◆ C4Network2ClientList()

C4Network2ClientList::C4Network2ClientList ( C4Network2IO pIO)

Definition at line 325 of file C4Network2Client.cpp.

326  : pIO(pIO), pFirst(nullptr), pLocal(nullptr)
327 {
328 
329 }
C4Network2Client * pFirst
C4Network2Client * pLocal

◆ ~C4Network2ClientList()

C4Network2ClientList::~C4Network2ClientList ( )

Definition at line 331 of file C4Network2Client.cpp.

References Clear().

332 {
333  Clear();
334 }
Here is the call graph for this function:

Member Function Documentation

◆ AllClientsReady()

bool C4Network2ClientList::AllClientsReady ( ) const

Definition at line 620 of file C4Network2Client.cpp.

References C4Network2Client::getNext(), and pFirst.

Referenced by C4Network2::CheckStatusAck().

621 {
622  for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->getNext())
623  if (!pClient->isLocal() && pClient->isWaitedFor() && !pClient->isReady())
624  return false;
625  return true;
626 }
C4Network2Client * getNext() const
C4Network2Client * pFirst
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BroadcastMsgToClients()

bool C4Network2ClientList::BroadcastMsgToClients ( const C4NetIOPacket rPkt)

Definition at line 489 of file C4Network2Client.cpp.

References C4PacketFwd::AddClient(), C4Network2IO::BeginBroadcast(), C4Network2IO::Broadcast(), C4Network2IO::EndBroadcast(), fHost, C4Network2Client::getNext(), MkC4NetIOPacket(), pFirst, PID_FwdReq, pIO, SendMsgToHost(), C4PacketFwd::SetData(), and C4PacketFwd::SetListType().

Referenced by C4GameLobby::Countdown::Abort(), C4Network2::ChangeGameStatus(), C4Network2::CheckStatusAck(), C4GameLobby::Countdown::Countdown(), C4GameControlNetwork::DoInput(), C4GameControlNetwork::ExecSyncControl(), C4Network2::LeagueEnd(), C4GameLobby::Countdown::OnSec1Timer(), and C4GameControlNetwork::SetCtrlMode().

490 {
491  // Send a msg to all clients, including clients that are not connected to
492  // this computer (will get forwarded by host).
493 
494  C4PacketFwd Fwd; Fwd.SetListType(true);
495  // lock
496  pIO->BeginBroadcast(false);
497  // select connections for broadcast
498  for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->getNext())
499  if (!pClient->isHost())
500  if (pClient->isConnected())
501  {
502  pClient->getMsgConn()->SetBroadcastTarget(true);
503  Fwd.AddClient(pClient->getID());
504  }
505  // broadcast
506  bool fSuccess = pIO->Broadcast(rPkt);
507  // unlock
508  pIO->EndBroadcast();
509  // clients: send forward request to host
510  if (!fHost)
511  {
512  Fwd.SetData(rPkt);
513  fSuccess &= SendMsgToHost(MkC4NetIOPacket(PID_FwdReq, Fwd));
514  }
515  return fSuccess;
516 }
bool SendMsgToHost(C4NetIOPacket rPkt)
C4Network2Client * getNext() const
C4Network2Client * pFirst
void AddClient(int32_t iClient)
Definition: C4Packet2.cpp:460
C4NetIOPacket MkC4NetIOPacket(char cStatus, const class C4PacketBase &Pkt, const C4NetIO::addr_t &addr=C4NetIO::addr_t())
Definition: C4PacketBase.h:40
void SetListType(bool fnNegativeList)
Definition: C4Packet2.cpp:455
bool Broadcast(const C4NetIOPacket &rPkt)
void BeginBroadcast(bool fSelectAll=false)
void EndBroadcast()
void SetData(const StdBuf &Pkt)
Definition: C4Packet2.cpp:450
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BroadcastMsgToConnClients()

bool C4Network2ClientList::BroadcastMsgToConnClients ( const C4NetIOPacket rPkt)

Definition at line 471 of file C4Network2Client.cpp.

References C4Network2IO::BeginBroadcast(), C4Network2IO::Broadcast(), C4Network2IO::EndBroadcast(), C4Network2Client::getNext(), pFirst, and pIO.

Referenced by C4Network2Client::AddAddr(), C4GameControlNetwork::CheckCompleteCtrl(), C4GameControlNetwork::Init(), C4GameControlNetwork::PackCompleteCtrl(), and C4Network2Client::SendAddresses().

472 {
473  // Send a msg to all clients that are currently directly reachable.
474 
475  // lock
476  pIO->BeginBroadcast(false);
477  // select connections for broadcast
478  for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->getNext())
479  if (pClient->isConnected())
480  pClient->getMsgConn()->SetBroadcastTarget(true);
481  // broadcast
482  bool fSuccess = pIO->Broadcast(rPkt);
483  // unlock
484  pIO->EndBroadcast();
485  // finished
486  return fSuccess;
487 }
C4Network2Client * getNext() const
C4Network2Client * pFirst
bool Broadcast(const C4NetIOPacket &rPkt)
void BeginBroadcast(bool fSelectAll=false)
void EndBroadcast()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Clear()

void C4Network2ClientList::Clear ( )

Definition at line 454 of file C4Network2Client.cpp.

References C4ClientList::ClearNetwork(), DeleteClient(), pClientList, pFirst, and pLocal.

Referenced by C4Network2::Clear(), C4ClientList::ClearNetwork(), C4ClientList::InitNetwork(), and ~C4Network2ClientList().

455 {
456  // remove link to main client list
457  if (pClientList)
458  {
459  C4ClientList *poClientList = pClientList;
460  pClientList = nullptr;
461  poClientList->ClearNetwork();
462  }
463  // delete clients
464  while (pFirst)
465  {
467  }
468  pLocal = nullptr;
469 }
void DeleteClient(C4Network2Client *pClient)
C4Network2Client * pFirst
void ClearNetwork()
Definition: C4Client.cpp:262
C4Network2Client * pLocal
C4ClientList * pClientList
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Count()

unsigned int C4Network2ClientList::Count ( )

Definition at line 379 of file C4Network2Client.cpp.

References pFirst, and C4Network2Client::pNext.

Referenced by C4Network2::OnClientDisconnect(), and C4GameLobby::Countdown::OnSec1Timer().

380 {
381  unsigned int ret(0);
382  for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->pNext) ret++;
383  return ret;
384 }
C4Network2Client * pFirst
C4Network2Client * pNext
Here is the caller graph for this function:

◆ DeleteClient()

void C4Network2ClientList::DeleteClient ( C4Network2Client pClient)

Definition at line 432 of file C4Network2Client.cpp.

References C4Network2Client::CloseConns(), C4Network2Client::getCore(), C4Network2Client::getNext(), pFirst, pIO, C4Network2Client::pNext, and C4Network2IO::RemoveAutoAccept().

Referenced by Clear().

433 {
434  // close connections
435  pClient->CloseConns("removing client");
436  // remove from list
437  if (pClient == pFirst)
438  pFirst = pClient->getNext();
439  else
440  {
441  C4Network2Client *pPrev;
442  for (pPrev = pFirst; pPrev && pPrev->getNext(); pPrev = pPrev->getNext())
443  if (pPrev->getNext() == pClient)
444  break;
445  if (pPrev && pPrev->getNext() == pClient)
446  pPrev->pNext = pClient->getNext();
447  }
448  // remove auto-accept
449  pIO->RemoveAutoAccept(pClient->getCore());
450  // delete
451  delete pClient;
452 }
C4Network2Client * getNext() const
C4Network2Client * pFirst
const C4ClientCore & getCore() const
void RemoveAutoAccept(const C4ClientCore &CCore)
C4Network2Client * pNext
void CloseConns(const char *szMsg)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoConnectAttempts()

void C4Network2ClientList::DoConnectAttempts ( )

Definition at line 601 of file C4Network2Client.cpp.

References C4Network2Client::getNext(), pFirst, and pIO.

Referenced by C4Network2::Execute().

602 {
603  // check interval
604  time_t t; time(&t);
605  for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->getNext())
606  {
607  if (!pClient->isLocal() && !pClient->isRemoved() && pClient->getNextConnAttempt() && pClient->getNextConnAttempt() <= t)
608  // attempt connect
609  pClient->DoConnectAttempt(pIO);
610  }
611 }
C4Network2Client * getNext() const
C4Network2Client * pFirst
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetClient() [1/3]

C4Network2Client * C4Network2ClientList::GetClient ( const char *  szName) const

Definition at line 355 of file C4Network2Client.cpp.

References pFirst, C4Network2Client::pNext, and SEqual().

Referenced by C4Network2::HandleConn(), C4Network2::HandleLobbyPacket(), C4Network2Players::HandlePacket(), HandlePacket(), C4Network2::HandlePacket(), C4Network2::Join(), and C4Network2::OnDisconn().

356 {
357  for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->pNext)
358  if (SEqual(pClient->getName(), szName))
359  return pClient;
360  return nullptr;
361 }
C4Network2Client * pFirst
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
C4Network2Client * pNext
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetClient() [2/3]

C4Network2Client * C4Network2ClientList::GetClient ( const C4ClientCore CCore,
int32_t  iMaxDiffLevel = C4ClientCoreDL_IDMatch 
)

Definition at line 371 of file C4Network2Client.cpp.

References pFirst, and C4Network2Client::pNext.

372 {
373  for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->pNext)
374  if (pClient->getCore().getDiffLevel(CCore) <= iMaxDiffLevel)
375  return pClient;
376  return nullptr;
377 }
C4Network2Client * pFirst
C4Network2Client * pNext

◆ GetClient() [3/3]

C4Network2Client * C4Network2ClientList::GetClient ( C4Network2IOConnection pConn) const

Definition at line 363 of file C4Network2Client.cpp.

References pFirst, and C4Network2Client::pNext.

364 {
365  for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->pNext)
366  if (pClient->hasConn(pConn))
367  return pClient;
368  return nullptr;
369 }
C4Network2Client * pFirst
C4Network2Client * pNext

◆ GetClientByID()

C4Network2Client * C4Network2ClientList::GetClientByID ( int32_t  iID) const

Definition at line 336 of file C4Network2Client.cpp.

References pFirst, and C4Network2Client::pNext.

Referenced by C4GameControlNetwork::CalcPerformance(), C4Control::CompileFunc(), GetHost(), C4Network2::HandleLobbyPacket(), C4Network2Players::HandlePacket(), HandlePacket(), C4Network2::HandlePacket(), C4Network2::OnConnectFail(), C4Network2::OnDisconn(), C4Network2Players::ResetUpdatedPlayers(), SendMsgToClient(), and C4Network2ClientDlg::UpdateText().

337 {
338  for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->pNext)
339  if (pClient->getID() == iID)
340  return pClient;
341  return nullptr;
342 }
C4Network2Client * pFirst
C4Network2Client * pNext
Here is the caller graph for this function:

◆ GetHost()

C4Network2Client * C4Network2ClientList::GetHost ( )

Definition at line 386 of file C4Network2Client.cpp.

References C4ClientIDHost, and GetClientByID().

Referenced by C4Network2::HandleConn(), C4Network2::OnDisconn(), and SendMsgToHost().

387 {
389 }
C4Network2Client * GetClientByID(int32_t iID) const
const int32_t C4ClientIDHost
Definition: C4Client.h:25
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetLocal()

C4Network2Client* C4Network2ClientList::GetLocal ( ) const
inline

Definition at line 162 of file C4Network2Client.h.

References C4Network2Client::pClient, and C4Network2Client::SendAddresses().

Referenced by C4Control::CompileFunc(), C4Network2Client::DoConnectAttempt(), C4Network2Client::DoTCPSimultaneousOpen(), C4Network2::DrawStatus(), C4Viewport::Execute(), C4Network2::InitialConnect::Execute(), C4Network2::InitNetIO(), C4Network2::LeagueNotifyDisconnect(), C4Network2::OnPuncherConnect(), and C4MessageInput::ProcessCommand().

162 { return pLocal; }
C4Network2Client * pLocal
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNextClient()

C4Network2Client * C4Network2ClientList::GetNextClient ( C4Network2Client pClient)

Definition at line 391 of file C4Network2Client.cpp.

References pFirst, and C4Network2Client::pNext.

Referenced by C4MainMenu::ActivateHost(), C4Network2Stats::C4Network2Stats(), C4Network2::DeactivateInactiveClients(), C4Network2::DrawStatus(), C4Network2Stats::ExecuteSecond(), C4Network2::OnGameSynchronized(), C4Network2::UpdateChaseTarget(), C4Console::UpdateNetMenu(), C4GameSave::WriteDescNetworkClients(), and C4Network2Stats::~C4Network2Stats().

392 {
393  return pClient ? pClient->pNext : pFirst;
394 }
C4Network2Client * pFirst
C4Network2Client * pNext
Here is the caller graph for this function:

◆ GetNextClientAfterID()

C4Network2Client * C4Network2ClientList::GetNextClientAfterID ( int32_t  iSmallerClientID) const

Definition at line 344 of file C4Network2Client.cpp.

References C4Network2Client::getID(), pFirst, and C4Network2Client::pNext.

345 {
346  // return client with smallest ID > iSmallerClientID
347  C4Network2Client *pBest = nullptr;
348  for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->pNext)
349  if (pClient->getID() > iSmallerClientID)
350  if (!pBest || pBest->getID() > pClient->getID())
351  pBest = pClient;
352  return pBest;
353 }
C4Network2Client * pFirst
C4Network2Client * pNext
int32_t getID() const
Here is the call graph for this function:

◆ HandlePacket()

void C4Network2ClientList::HandlePacket ( char  cStatus,
const C4PacketBase pBasePkt,
C4Network2IOConnection pConn 
)

Definition at line 543 of file C4Network2Client.cpp.

References C4Network2Client::AddAddr(), C4Network2Client::DoConnectAttempt(), C4Network2Client::DoTCPSimultaneousOpen(), C4Network2Address::getAddr(), GetClient(), GetClientByID(), C4Network2IOConnection::getPeerAddr(), GETPKT, C4Network2Address::isIPNull(), PID_Addr, PID_TCPSimOpen, pIO, and C4Network2Address::SetIP().

Referenced by C4Network2IO::CallHandlers().

544 {
545  // find associated client
546  C4Network2Client *pClient = GetClient(pConn);
547  if (!pClient) return;
548 
549 #define GETPKT(type, name) \
550  assert(pBasePkt); const type &name = \
551  static_cast<const type &>(*pBasePkt);
552 
553  switch (cStatus)
554  {
555 
556  case PID_Addr: // address propagation
557  {
558  GETPKT(C4PacketAddr, rPkt)
559  // find client
560  pClient = GetClientByID(rPkt.getClientID());
561  if (pClient)
562  {
563  C4Network2Address addr = rPkt.getAddr();
564  // IP zero? Set to IP from where the packet came
565  if (addr.isIPNull())
566  {
567  addr.SetIP(pConn->getPeerAddr());
568  }
569  // add (no announce)
570  if (pClient->AddAddr(addr, true))
571  // new address? Try to connect
572  pClient->DoConnectAttempt(pIO);
573  }
574  }
575  break;
576 
577  case PID_TCPSimOpen:
578  {
580  pClient = GetClientByID(rPkt.getClientID());
581  if (pClient)
582  {
583  C4Network2Address addr = rPkt.getAddr();
584  pClient->DoTCPSimultaneousOpen(pIO, addr);
585  }
586  }
587  break;
588 
589  }
590 
591 #undef GETPKT
592 }
bool isIPNull() const
const C4NetIO::addr_t & getPeerAddr() const
Definition: C4Network2IO.h:266
#define GETPKT(type, name)
C4Network2Client * GetClientByID(int32_t iID) const
bool DoTCPSimultaneousOpen(class C4Network2IO *pIO, const C4Network2Address &addr)
bool DoConnectAttempt(class C4Network2IO *pIO)
void SetIP(C4NetIO::addr_t ip)
C4Network2Client * GetClient(const char *szName) const
bool AddAddr(const C4Network2Address &addr, bool fAnnounce)
const C4NetIO::addr_t & getAddr() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init()

void C4Network2ClientList::Init ( C4ClientList pClientList,
bool  fHost 
)

Definition at line 396 of file C4Network2Client.cpp.

References fHost, C4ClientList::InitNetwork(), and pClientList.

Referenced by C4Network2::InitialConnect::Execute(), C4ClientList::getLocalID(), and C4Network2::InitHost().

397 {
398  // save flag
399  fHost = fnHost;
400  // initialize
401  pClientList = pnClientList;
402  pClientList->InitNetwork(this);
403 }
void InitNetwork(class C4Network2ClientList *pNetClients)
Definition: C4Client.cpp:251
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegClient()

C4Network2Client * C4Network2ClientList::RegClient ( C4Client pClient)

Definition at line 405 of file C4Network2Client.cpp.

References C4Network2IO::AddAutoAccept(), C4Client::getCore(), C4Client::getID(), C4Client::getNetClient(), C4Network2Client::getNext(), C4Client::isLocal(), pFirst, pIO, and pLocal.

Referenced by C4ClientList::InitNetwork().

406 {
407  // security
408  if (pClient->getNetClient())
409  return pClient->getNetClient();
410  // find insert position
411  C4Network2Client *pPos = pFirst, *pLast = nullptr;
412  for (; pPos; pLast = pPos, pPos = pPos->getNext())
413  if (pPos->getID() > pClient->getID())
414  break;
415  assert(!pLast || pLast->getID() != pClient->getID());
416  // create new client
417  C4Network2Client *pNetClient = new C4Network2Client(pClient);
418  // add to list
419  pNetClient->pNext = pPos;
420  (pLast ? pLast->pNext : pFirst) = pNetClient;
421  pNetClient->pParent = this;
422  // local?
423  if (pClient->isLocal())
424  pLocal = pNetClient;
425  else
426  // set auto-accept
427  pIO->AddAutoAccept(pClient->getCore());
428  // add
429  return pNetClient;
430 }
C4Network2Client * getNext() const
C4Network2Client * getNetClient() const
Definition: C4Client.h:117
void AddAutoAccept(const C4ClientCore &CCore)
const C4ClientCore & getCore() const
Definition: C4Client.h:104
C4Network2Client * pFirst
C4Network2Client * pLocal
bool isLocal() const
Definition: C4Client.h:116
int32_t getID() const
Definition: C4Client.h:105
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetReady()

void C4Network2ClientList::ResetReady ( )

Definition at line 613 of file C4Network2Client.cpp.

References C4Network2Client::getNext(), NCS_NotReady, and pFirst.

Referenced by C4Network2::ChangeGameStatus().

614 {
615  for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->getNext())
616  if (pClient->isWaitedFor())
617  pClient->SetStatus(NCS_NotReady);
618 }
C4Network2Client * getNext() const
C4Network2Client * pFirst
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendAddresses()

void C4Network2ClientList::SendAddresses ( C4Network2IOConnection pConn)

Definition at line 594 of file C4Network2Client.cpp.

References C4Network2Client::getNext(), and pFirst.

Referenced by C4Network2::HandleJoinData(), and C4Network2::SendJoinData().

595 {
596  // send all client addresses known
597  for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->getNext())
598  pClient->SendAddresses(pConn);
599 }
C4Network2Client * getNext() const
C4Network2Client * pFirst
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendMsgToClient()

bool C4Network2ClientList::SendMsgToClient ( int32_t  iClient,
C4NetIOPacket &&  rPkt 
)

Definition at line 528 of file C4Network2Client.cpp.

References C4PacketFwd::AddClient(), GetClientByID(), C4Network2Client::isConnected(), MkC4NetIOPacket(), PID_FwdReq, C4Network2Client::SendMsg(), SendMsgToHost(), C4PacketFwd::SetData(), and C4PacketFwd::SetListType().

Referenced by C4Network2::OnDisconn().

529 {
530  // find client
531  C4Network2Client *pClient = GetClientByID(iClient);
532  if (!pClient) return false;
533  // connected? send directly
534  if (pClient->isConnected())
535  return pClient->SendMsg(rPkt);
536  // forward
537  C4PacketFwd Fwd; Fwd.SetListType(false);
538  Fwd.AddClient(iClient);
539  Fwd.SetData(rPkt);
541 }
bool SendMsgToHost(C4NetIOPacket rPkt)
bool SendMsg(C4NetIOPacket rPkt) const
bool isConnected() const
void AddClient(int32_t iClient)
Definition: C4Packet2.cpp:460
C4NetIOPacket MkC4NetIOPacket(char cStatus, const class C4PacketBase &Pkt, const C4NetIO::addr_t &addr=C4NetIO::addr_t())
Definition: C4PacketBase.h:40
void SetListType(bool fnNegativeList)
Definition: C4Packet2.cpp:455
C4Network2Client * GetClientByID(int32_t iID) const
void SetData(const StdBuf &Pkt)
Definition: C4Packet2.cpp:450
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendMsgToHost()

bool C4Network2ClientList::SendMsgToHost ( C4NetIOPacket  rPkt)

Definition at line 518 of file C4Network2Client.cpp.

References GetHost(), C4Network2Client::getMsgConn(), and C4Network2Client::SendMsg().

Referenced by BroadcastMsgToClients(), C4GameControlNetwork::CheckCompleteCtrl(), C4Network2::CheckStatusReached(), C4GameControlNetwork::DoInput(), C4Network2Players::JoinLocalPlayer(), C4Network2::RequestActivate(), C4Network2Players::RequestPlayerInfoUpdate(), and SendMsgToClient().

519 {
520  // find host
521  C4Network2Client *pHost = GetHost();
522  if (!pHost) return false;
523  // send message
524  if (!pHost->getMsgConn()) return false;
525  return pHost->SendMsg(rPkt);
526 }
bool SendMsg(C4NetIOPacket rPkt) const
C4Network2IOConnection * getMsgConn() const
C4Network2Client * GetHost()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateClientActivity()

void C4Network2ClientList::UpdateClientActivity ( )

Definition at line 628 of file C4Network2Client.cpp.

References C4Game::FrameCounter, Game, C4PlayerList::GetAtClient(), C4Network2Client::getNext(), pFirst, and Players.

Referenced by C4Network2::DeactivateInactiveClients().

629 {
630  for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->getNext())
631  if (pClient->isActivated())
632  if (::Players.GetAtClient(pClient->getID()))
633  pClient->SetLastActivity(Game.FrameCounter);
634 }
C4Network2Client * getNext() const
C4Game Game
Definition: C4Globals.cpp:52
C4Network2Client * pFirst
int32_t FrameCounter
Definition: C4Game.h:129
C4PlayerList Players
C4Player * GetAtClient(int iClient, int iIndex=0) const
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fHost

bool C4Network2ClientList::fHost
protected

Definition at line 154 of file C4Network2Client.h.

Referenced by BroadcastMsgToClients(), and Init().

◆ pClientList

C4ClientList* C4Network2ClientList::pClientList
protected

Definition at line 153 of file C4Network2Client.h.

Referenced by Clear(), and Init().

◆ pFirst

◆ pIO

C4Network2IO* C4Network2ClientList::pIO
protected

◆ pLocal

C4Network2Client* C4Network2ClientList::pLocal
protected

The documentation for this class was generated from the following files: