OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Network2Client Class Reference

#include <C4Network2Client.h>

Collaboration diagram for C4Network2Client:
[legend]

Public Member Functions

 C4Network2Client (C4Client *pClient)
 
 ~C4Network2Client ()
 
C4ClientgetClient () const
 
const C4ClientCoregetCore () const
 
int32_t getID () const
 
bool isLocal () const
 
bool isHost () const
 
const char * getName () const
 
bool isActivated () const
 
bool isObserver () const
 
int32_t getAddrCnt () const
 
const C4Network2AddressgetAddr (int32_t i) const
 
const std::set< int > & getInterfaceIDs () const
 
C4Network2ClientStatus getStatus () const
 
bool hasJoinData () const
 
bool isChasing () const
 
bool isReady () const
 
bool isWaitedFor () const
 
bool isRemoved () const
 
bool isConnected () const
 
time_t getNextConnAttempt () const
 
int32_t getLastActivity () const
 
class C4TableGraphgetStatPing () const
 
C4Network2ClientgetNext () const
 
void SetStatus (C4Network2ClientStatus enStatus)
 
void SetLastActivity (int32_t iTick)
 
C4Network2IOConnectiongetMsgConn () const
 
C4Network2IOConnectiongetDataConn () const
 
bool hasConn (C4Network2IOConnection *pConn)
 
void SetMsgConn (C4Network2IOConnection *pConn)
 
void SetDataConn (C4Network2IOConnection *pConn)
 
void RemoveConn (C4Network2IOConnection *pConn)
 
void CloseConns (const char *szMsg)
 
bool SendMsg (C4NetIOPacket rPkt) const
 
bool SendData (C4NetIOPacket rPkt) const
 
bool DoConnectAttempt (class C4Network2IO *pIO)
 
bool hasAddr (const C4Network2Address &addr) const
 
void ClearAddr ()
 
bool AddAddr (const C4Network2Address &addr, bool fAnnounce)
 
void AddLocalAddrs (int16_t iPortTCP, int16_t iPortUDP)
 
void SendAddresses (C4Network2IOConnection *pConn)
 
void CreateGraphs ()
 
void ClearGraphs ()
 

Protected Attributes

C4ClientpClient
 
C4Network2Address Addr [C4ClientMaxAddr]
 
int32_t AddrAttempts [C4ClientMaxAddr]
 
int32_t iAddrCnt
 
std::set< int > InterfaceIDs
 
C4Network2ClientStatus eStatus
 
int32_t iLastActivity
 
C4Network2IOConnectionpMsgConn
 
C4Network2IOConnectionpDataConn
 
time_t iNextConnAttempt
 
C4Network2ClientpNext
 
class C4Network2ClientListpParent
 
class C4TableGraphpstatPing
 

Friends

class C4Network2ClientList
 

Detailed Description

Definition at line 44 of file C4Network2Client.h.

Constructor & Destructor Documentation

C4Network2Client::C4Network2Client ( C4Client pClient)

Definition at line 27 of file C4Network2Client.cpp.

28  : pClient(pClient),
29  iAddrCnt(0),
31  iLastActivity(0),
32  pMsgConn(nullptr), pDataConn(nullptr),
34  pNext(nullptr), pParent(nullptr), pstatPing(nullptr)
35 {
36 }
class C4Network2ClientList * pParent
class C4TableGraph * pstatPing
C4Network2IOConnection * pDataConn
C4Network2Client * pNext
C4Network2ClientStatus eStatus
C4Network2IOConnection * pMsgConn
C4Network2Client::~C4Network2Client ( )

Definition at line 38 of file C4Network2Client.cpp.

References ClearGraphs(), C4Network2IOConnection::Close(), C4Network2IOConnection::DelRef(), pClient, pDataConn, pMsgConn, and C4Client::UnlinkNetClient().

39 {
40  ClearGraphs();
41  if (pMsgConn) { pMsgConn->Close(); pMsgConn->DelRef(); } pMsgConn = nullptr;
42  if (pDataConn) { pDataConn->Close(); pDataConn->DelRef(); } pDataConn = nullptr;
44 }
void UnlinkNetClient()
Definition: C4Client.h:129
C4Network2IOConnection * pDataConn
C4Network2IOConnection * pMsgConn

Here is the call graph for this function:

Member Function Documentation

bool C4Network2Client::AddAddr ( const C4Network2Address addr,
bool  fAnnounce 
)

Definition at line 169 of file C4Network2Client.cpp.

References Addr, AddrAttempts, C4Network2ClientList::BroadcastMsgToConnClients(), C4ClientMaxAddr, getID(), hasAddr(), iAddrCnt, iNextConnAttempt, MkC4NetIOPacket(), PID_Addr, and pParent.

Referenced by AddLocalAddrs(), C4Network2::HandleConnRe(), C4Network2ClientList::HandlePacket(), and C4Network2::OnPuncherConnect().

170 {
171  // checks
172  if (iAddrCnt + 1 >= C4ClientMaxAddr) return false;
173  if (hasAddr(addr)) return true;
174  // add
175  Addr[iAddrCnt] = addr; AddrAttempts[iAddrCnt] = 0;
176  iAddrCnt++;
177  // attempt to use this one
178  if (!iNextConnAttempt) iNextConnAttempt = time(nullptr);
179  // announce
180  if (fAnnounce)
182  return false;
183  // done
184  return true;
185 }
class C4Network2ClientList * pParent
bool hasAddr(const C4Network2Address &addr) const
int32_t getID() const
C4NetIOPacket MkC4NetIOPacket(char cStatus, const class C4PacketBase &Pkt, const C4NetIO::addr_t &addr=C4NetIO::addr_t())
Definition: C4PacketBase.h:40
C4Network2Address Addr[C4ClientMaxAddr]
const int32_t C4ClientMaxAddr
int32_t AddrAttempts[C4ClientMaxAddr]
bool BroadcastMsgToConnClients(const C4NetIOPacket &rPkt)

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Network2Client::AddLocalAddrs ( int16_t  iPortTCP,
int16_t  iPortUDP 
)

Definition at line 187 of file C4Network2Client.cpp.

References AddAddr(), C4NetIO::GetLocalAddresses(), C4NetIO::HostAddress::GetScopeId(), InterfaceIDs, P_TCP, P_UDP, C4NetIO::EndpointAddress::SetAddress(), and C4NetIO::EndpointAddress::SetPort().

Referenced by C4Network2::InitNetIO().

188 {
189  C4NetIO::addr_t addr;
190 
191  for (auto& ha : C4NetIO::GetLocalAddresses())
192  {
193  addr.SetAddress(ha);
194  if (iPortTCP)
195  {
196  addr.SetPort(iPortTCP);
197  AddAddr(C4Network2Address(addr, P_TCP), false);
198  }
199  if (iPortUDP)
200  {
201  addr.SetPort(iPortUDP);
202  AddAddr(C4Network2Address(addr, P_UDP), false);
203  }
204  if (addr.GetScopeId())
205  InterfaceIDs.insert(addr.GetScopeId());
206  }
207 }
void SetAddress(const sockaddr *addr)
Definition: C4NetIO.cpp:364
int GetScopeId() const
Definition: C4NetIO.cpp:296
static std::vector< HostAddress > GetLocalAddresses()
Definition: C4NetIO.cpp:626
std::set< int > InterfaceIDs
void SetPort(uint16_t port)
Definition: C4NetIO.cpp:526
bool AddAddr(const C4Network2Address &addr, bool fAnnounce)

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Network2Client::ClearAddr ( )

Definition at line 164 of file C4Network2Client.cpp.

References iAddrCnt.

165 {
166  iAddrCnt = 0;
167 }
void C4Network2Client::ClearGraphs ( )

Definition at line 243 of file C4Network2Client.cpp.

References Game, C4Game::pNetworkStatistics, and pstatPing.

Referenced by CreateGraphs(), ~C4Network2Client(), and C4Network2Stats::~C4Network2Stats().

244 {
245  // del all assigned graphs
246  if (pstatPing)
247  {
248  if (Game.pNetworkStatistics) Game.pNetworkStatistics->statPings.RemoveGraph(pstatPing);
249  delete pstatPing;
250  pstatPing = nullptr;
251  }
252 }
C4Game Game
Definition: C4Globals.cpp:52
class C4TableGraph * pstatPing
std::unique_ptr< C4Network2Stats > pNetworkStatistics
Definition: C4Game.h:95

Here is the caller graph for this function:

void C4Network2Client::CloseConns ( const char *  szMsg)

Definition at line 86 of file C4Network2Client.cpp.

References C4Network2IOConnection::Close(), C4Network2IOConnection::isOpen(), MkC4NetIOPacket(), PID_ConnRe, pMsgConn, RemoveConn(), and C4Network2IOConnection::Send().

Referenced by C4Network2ClientList::DeleteClient().

87 {
88  C4PacketConnRe Pkt(false, false, szMsg);
90  while ((pConn = pMsgConn))
91  {
92  // send packet, close
93  if (pConn->isOpen())
94  {
95  pConn->Send(MkC4NetIOPacket(PID_ConnRe, Pkt));
96  pConn->Close();
97  }
98  // remove
99  RemoveConn(pConn);
100  }
101 }
void RemoveConn(C4Network2IOConnection *pConn)
bool Send(const C4NetIOPacket &rPkt)
C4NetIOPacket MkC4NetIOPacket(char cStatus, const class C4PacketBase &Pkt, const C4NetIO::addr_t &addr=C4NetIO::addr_t())
Definition: C4PacketBase.h:40
C4Network2IOConnection * pMsgConn
bool isOpen() const
Definition: C4Network2IO.h:285

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Network2Client::CreateGraphs ( )

Definition at line 227 of file C4Network2Client.cpp.

References ClearGraphs(), C4TableGraph::DefaultBlockLength, Game, getID(), getName(), C4Game::pNetworkStatistics, and pstatPing.

Referenced by C4Network2Stats::C4Network2Stats().

228 {
229  // del prev
230  ClearGraphs();
231  // get client color
232  static const DWORD ClientDefColors[] = {0xff0000, 0x00ff00, 0xffff00, 0x7f7fff, 0xffffff, 0x00ffff, 0xff00ff, 0x7f7f7f, 0xff7f7f, 0x7fff7f, 0x0000ff};
233  int32_t iClientColorNum = sizeof(ClientDefColors)/sizeof(DWORD);
234  DWORD dwClientClr = ClientDefColors[std::max<int32_t>(getID(), 0) % iClientColorNum];
235  // create graphs
237  pstatPing->SetColorDw(dwClientClr);
238  pstatPing->SetTitle(getName());
239  // register into stat module
240  if (Game.pNetworkStatistics) Game.pNetworkStatistics->statPings.AddGraph(pstatPing);
241 }
C4Game Game
Definition: C4Globals.cpp:52
int32_t getID() const
class C4TableGraph * pstatPing
const char * getName() const
std::unique_ptr< C4Network2Stats > pNetworkStatistics
Definition: C4Game.h:95
uint32_t DWORD

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Network2Client::DoConnectAttempt ( class C4Network2IO pIO)

Definition at line 113 of file C4Network2Client.cpp.

References Addr, AddrAttempts, C4NetClientConnectAttempts, C4NetClientConnectInterval, C4Network2::Clients, C4Network2IO::Connect(), C4Network2Address::getAddr(), C4Client::getCore(), getDataConn(), getInterfaceIDs(), C4Network2ClientList::GetLocal(), getMsgConn(), getName(), C4Network2IO::getNetIO(), C4Network2Address::getProtocol(), C4Network2IOConnection::getProtocol(), iAddrCnt, iNextConnAttempt, isLocal(), LogSilentF(), Network, pClient, pDataConn, and pMsgConn.

Referenced by C4Network2ClientList::HandlePacket().

114 {
115  // local?
116  if (isLocal()) { iNextConnAttempt = 0; return true; }
117  // msg and data connected? Nothing to do
118  if (getMsgConn() != getDataConn()) { iNextConnAttempt = time(nullptr) + 10; return true; }
119  // too early?
120  if (iNextConnAttempt && iNextConnAttempt > time(nullptr)) return true;
121  // find address to try
122  int32_t iBestAddress = -1;
123  for (int32_t i = 0; i < iAddrCnt; i++)
124  // no connection for this protocol?
125  if ((!pDataConn || Addr[i].getProtocol() != pDataConn->getProtocol()) &&
126  (!pMsgConn || Addr[i].getProtocol() != pMsgConn->getProtocol()))
127  // protocol available?
128  if (pIO->getNetIO(Addr[i].getProtocol()))
129  // new best address?
130  if (iBestAddress < 0 || AddrAttempts[i] < AddrAttempts[iBestAddress])
131  iBestAddress = i;
132  // too many attempts or nothing found?
133  if (iBestAddress < 0 || AddrAttempts[iBestAddress] > C4NetClientConnectAttempts)
134  { iNextConnAttempt = time(nullptr) + 10; return true; }
135  // save attempt
136  AddrAttempts[iBestAddress]++; iNextConnAttempt = time(nullptr) + C4NetClientConnectInterval;
137  auto addr = Addr[iBestAddress].getAddr();
138  std::set<int> interfaceIDs;
139  if (addr.IsLocal())
140  interfaceIDs = Network.Clients.GetLocal()->getInterfaceIDs();
141  else
142  interfaceIDs = {0};
143  for (auto id : interfaceIDs)
144  {
145  addr.SetScopeId(id);
146  // log
147  LogSilentF("Network: connecting client %s on %s...", getName(), addr.ToString().getData());
148  // connect
149  if (pIO->Connect(addr, Addr[iBestAddress].getProtocol(), pClient->getCore()))
150  return true;
151  }
152  return false;
153 }
C4Network2IOConnection * getMsgConn() const
C4Network2IOConnection * getDataConn() const
C4Network2IOProtocol getProtocol() const
Definition: C4Network2IO.h:263
bool LogSilentF(const char *strMessage,...)
Definition: C4Log.cpp:260
C4Network2 Network
Definition: C4Globals.cpp:53
C4Network2Address Addr[C4ClientMaxAddr]
const C4ClientCore & getCore() const
Definition: C4Client.h:104
const int32_t C4NetClientConnectInterval
const std::set< int > & getInterfaceIDs() const
const char * getName() const
C4Network2IOConnection * pDataConn
const int32_t C4NetClientConnectAttempts
C4Network2IOProtocol getProtocol() const
C4Network2ClientList Clients
Definition: C4Network2.h:116
bool isLocal() const
int32_t AddrAttempts[C4ClientMaxAddr]
C4Network2Client * GetLocal() const
C4Network2IOConnection * pMsgConn
const C4NetIO::addr_t & getAddr() const

Here is the call graph for this function:

Here is the caller graph for this function:

const C4Network2Address& C4Network2Client::getAddr ( int32_t  i) const
inline

Definition at line 92 of file C4Network2Client.h.

Referenced by C4Network2Reference::InitLocal(), SendAddresses(), and C4Network2ClientDlg::UpdateText().

92 { return Addr[i]; }
C4Network2Address Addr[C4ClientMaxAddr]

Here is the caller graph for this function:

int32_t C4Network2Client::getAddrCnt ( ) const
inline

Definition at line 91 of file C4Network2Client.h.

References iAddrCnt.

Referenced by C4Network2Reference::InitLocal(), and C4Network2ClientDlg::UpdateText().

91 { return iAddrCnt; }

Here is the caller graph for this function:

C4Client* C4Network2Client::getClient ( ) const
inline

Definition at line 82 of file C4Network2Client.h.

References pClient.

Referenced by getCore(), C4Network2::OnClientConnect(), C4Network2::OnClientDisconnect(), and C4Network2::OnGameSynchronized().

82 { return pClient; }

Here is the caller graph for this function:

const C4ClientCore& C4Network2Client::getCore ( ) const
inline

Definition at line 83 of file C4Network2Client.h.

References getClient(), and C4Client::getCore().

Referenced by C4Network2::CheckConn(), C4Network2ClientList::DeleteClient(), getID(), getName(), C4Network2::HandleConnRe(), isActivated(), and isObserver().

83 { return getClient()->getCore(); }
const C4ClientCore & getCore() const
Definition: C4Client.h:104
C4Client * getClient() const

Here is the call graph for this function:

Here is the caller graph for this function:

C4Network2IOConnection* C4Network2Client::getDataConn ( ) const
inline

Definition at line 114 of file C4Network2Client.h.

References pDataConn.

Referenced by DoConnectAttempt(), SendData(), C4Network2ClientListBox::Update(), and C4Network2ClientDlg::UpdateText().

114 { return pDataConn; }
C4Network2IOConnection * pDataConn

Here is the caller graph for this function:

int32_t C4Network2Client::getID ( ) const
inline

Definition at line 84 of file C4Network2Client.h.

References getCore(), and C4ClientCore::getID().

Referenced by AddAddr(), CreateGraphs(), C4Network2::DrawStatus(), C4Network2ClientList::GetNextClientAfterID(), C4Network2::HandleActivateReq(), isHost(), C4Network2::LeagueNotifyDisconnect(), C4Network2::OnClientDisconnect(), C4MessageInput::ProcessCommand(), SendAddresses(), and C4Network2::SendJoinData().

84 { return getCore().getID(); }
const C4ClientCore & getCore() const
int32_t getID() const
Definition: C4Client.h:57

Here is the call graph for this function:

Here is the caller graph for this function:

const std::set<int>& C4Network2Client::getInterfaceIDs ( ) const
inline

Definition at line 94 of file C4Network2Client.h.

References InterfaceIDs.

Referenced by DoConnectAttempt().

94 { return InterfaceIDs; }
std::set< int > InterfaceIDs

Here is the caller graph for this function:

int32_t C4Network2Client::getLastActivity ( ) const
inline

Definition at line 105 of file C4Network2Client.h.

References iLastActivity.

105 { return iLastActivity; }
C4Network2IOConnection* C4Network2Client::getMsgConn ( ) const
inline

Definition at line 113 of file C4Network2Client.h.

References pMsgConn.

Referenced by C4GameControlNetwork::CalcPerformance(), DoConnectAttempt(), C4Network2Stats::ExecuteSecond(), C4Network2::HandleActivateReq(), C4Network2::SendJoinData(), SendMsg(), C4Network2ClientList::SendMsgToHost(), C4Network2ClientListBox::Update(), and C4Network2ClientDlg::UpdateText().

113 { return pMsgConn; }
C4Network2IOConnection * pMsgConn

Here is the caller graph for this function:

const char* C4Network2Client::getName ( ) const
inline

Definition at line 87 of file C4Network2Client.h.

References getCore(), and C4ClientCore::getName().

Referenced by CreateGraphs(), DoConnectAttempt(), C4Network2::DrawStatus(), C4Network2::HandleConnRe(), C4Network2::OnClientDisconnect(), C4Network2::OnConnect(), and C4Network2::OnDisconnect().

87 { return getCore().getName(); }
const C4ClientCore & getCore() const
const char * getName() const
Definition: C4Client.h:69

Here is the call graph for this function:

Here is the caller graph for this function:

C4Network2Client* C4Network2Client::getNext ( ) const
inline
time_t C4Network2Client::getNextConnAttempt ( ) const
inline

Definition at line 104 of file C4Network2Client.h.

References iNextConnAttempt.

104 { return iNextConnAttempt; }
class C4TableGraph* C4Network2Client::getStatPing ( ) const
inline

Definition at line 106 of file C4Network2Client.h.

References pstatPing.

Referenced by C4Network2Stats::ExecuteSecond().

106 { return pstatPing; }
class C4TableGraph * pstatPing

Here is the caller graph for this function:

C4Network2ClientStatus C4Network2Client::getStatus ( ) const
inline

Definition at line 96 of file C4Network2Client.h.

References eStatus.

Referenced by hasJoinData(), isChasing(), isReady(), isRemoved(), and isWaitedFor().

96 { return eStatus; }
C4Network2ClientStatus eStatus

Here is the caller graph for this function:

bool C4Network2Client::hasAddr ( const C4Network2Address addr) const

Definition at line 155 of file C4Network2Client.cpp.

References Addr, and iAddrCnt.

Referenced by AddAddr().

156 {
157  // Note that the host only knows its own address as 0.0.0.0, so if the real address is being added, that can't be sorted out.
158  for (int32_t i = 0; i < iAddrCnt; i++)
159  if (Addr[i] == addr)
160  return true;
161  return false;
162 }
C4Network2Address Addr[C4ClientMaxAddr]

Here is the caller graph for this function:

bool C4Network2Client::hasConn ( C4Network2IOConnection pConn)

Definition at line 46 of file C4Network2Client.cpp.

References pDataConn, and pMsgConn.

Referenced by C4Network2::CheckConn().

47 {
48  return pMsgConn == pConn || pDataConn == pConn;
49 }
C4Network2IOConnection * pDataConn
C4Network2IOConnection * pMsgConn

Here is the caller graph for this function:

bool C4Network2Client::hasJoinData ( ) const
inline

Definition at line 97 of file C4Network2Client.h.

References getStatus(), and NCS_Joining.

Referenced by C4Network2::HandleStatusAck(), C4Network2::OnClientConnect(), C4Network2::OnGameSynchronized(), and C4Network2::SendJoinData().

97 { return getStatus() != NCS_Joining; }
C4Network2ClientStatus getStatus() const

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Network2Client::isActivated ( ) const
inline

Definition at line 88 of file C4Network2Client.h.

References getCore(), and C4ClientCore::isActivated().

Referenced by C4Network2::DrawStatus(), and C4Network2::HandleActivateReq().

88 { return getCore().isActivated(); }
bool isActivated() const
Definition: C4Client.h:59
const C4ClientCore & getCore() const

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Network2Client::isChasing ( ) const
inline

Definition at line 98 of file C4Network2Client.h.

References getStatus(), and NCS_Chasing.

Referenced by C4Network2::UpdateChaseTarget().

98 { return getStatus() == NCS_Chasing; }
C4Network2ClientStatus getStatus() const

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Network2Client::isConnected ( ) const
inline

Definition at line 103 of file C4Network2Client.h.

References pMsgConn.

Referenced by C4Network2::HandleConnRe(), C4Network2::OnDisconn(), C4Network2::OnDisconnect(), C4Network2ClientList::SendMsgToClient(), and C4Network2ClientDlg::UpdateText().

103 { return !! pMsgConn; }
C4Network2IOConnection * pMsgConn

Here is the caller graph for this function:

bool C4Network2Client::isHost ( ) const
inline

Definition at line 86 of file C4Network2Client.h.

References C4ClientIDHost, and getID().

Referenced by C4Network2::DrawStatus(), C4Network2Players::HandlePacket(), C4Network2::HandlePacket(), C4Network2::OnClientDisconnect(), and C4Network2::OnConnect().

86 { return getID() == C4ClientIDHost; }
int32_t getID() 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:

bool C4Network2Client::isLocal ( ) const
inline

Definition at line 85 of file C4Network2Client.h.

References C4Client::isLocal().

Referenced by C4GameControlNetwork::CalcPerformance(), DoConnectAttempt(), and C4Network2::HandlePacket().

85 { return pClient->isLocal(); }
bool isLocal() const
Definition: C4Client.h:116

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Network2Client::isObserver ( ) const
inline

Definition at line 89 of file C4Network2Client.h.

References getCore(), and C4ClientCore::isObserver().

Referenced by C4Network2::DrawStatus(), C4Viewport::Execute(), and C4Network2::HandleActivateReq().

89 { return getCore().isObserver(); }
bool isObserver() const
Definition: C4Client.h:60
const C4ClientCore & getCore() const

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Network2Client::isReady ( ) const
inline

Definition at line 99 of file C4Network2Client.h.

References getStatus(), and NCS_Ready.

Referenced by C4Network2ClientDlg::UpdateText().

99 { return getStatus() == NCS_Ready; }
C4Network2ClientStatus getStatus() const

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Network2Client::isRemoved ( ) const
inline

Definition at line 101 of file C4Network2Client.h.

References getStatus(), and NCS_Remove.

Referenced by C4Network2::HandleStatusAck().

101 { return getStatus() == NCS_Remove; }
C4Network2ClientStatus getStatus() const

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Network2Client::isWaitedFor ( ) const
inline

Definition at line 100 of file C4Network2Client.h.

References getStatus(), NCS_NotReady, and NCS_Ready.

Referenced by C4Network2::HandleActivateReq().

100 { return getStatus() == NCS_NotReady || getStatus() == NCS_Ready; }
C4Network2ClientStatus getStatus() const

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Network2Client::RemoveConn ( C4Network2IOConnection pConn)

Definition at line 75 of file C4Network2Client.cpp.

References C4Network2IOConnection::DelRef(), pDataConn, pMsgConn, SetDataConn(), and SetMsgConn().

Referenced by CloseConns(), and C4Network2::OnDisconn().

76 {
77  if (pConn == pMsgConn)
78  { pMsgConn->DelRef(); pMsgConn = nullptr; }
79  if (pConn == pDataConn)
80  { pDataConn->DelRef(); pDataConn = nullptr; }
83 }
void SetMsgConn(C4Network2IOConnection *pConn)
void SetDataConn(C4Network2IOConnection *pConn)
C4Network2IOConnection * pDataConn
C4Network2IOConnection * pMsgConn

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Network2Client::SendAddresses ( C4Network2IOConnection pConn)

Definition at line 209 of file C4Network2Client.cpp.

References Addr, C4Network2ClientList::BroadcastMsgToConnClients(), C4Network2Address::getAddr(), getAddr(), getID(), C4Network2IOConnection::getPeerAddr(), C4NetIO::HostAddress::GetScopeId(), iAddrCnt, MkC4NetIOPacket(), PID_Addr, pParent, C4Network2IOConnection::Send(), and C4NetIO::HostAddress::SetScopeId().

210 {
211  // send all addresses
212  for (int32_t i = 0; i < iAddrCnt; i++)
213  {
214  if (Addr[i].getAddr().GetScopeId() && (!pConn || pConn->getPeerAddr().GetScopeId() != Addr[i].getAddr().GetScopeId()))
215  continue;
216  C4Network2Address addr(Addr[i]);
217  addr.getAddr().SetScopeId(0);
219  if (pConn)
220  pConn->Send(Pkt);
221  else
223  }
224 
225 }
const C4Network2Address & getAddr(int32_t i) const
class C4Network2ClientList * pParent
bool Send(const C4NetIOPacket &rPkt)
int32_t getID() const
const C4NetIO::addr_t & getPeerAddr() const
Definition: C4Network2IO.h:264
int GetScopeId() const
Definition: C4NetIO.cpp:296
C4NetIOPacket MkC4NetIOPacket(char cStatus, const class C4PacketBase &Pkt, const C4NetIO::addr_t &addr=C4NetIO::addr_t())
Definition: C4PacketBase.h:40
C4Network2Address Addr[C4ClientMaxAddr]
bool BroadcastMsgToConnClients(const C4NetIOPacket &rPkt)
const C4NetIO::addr_t & getAddr() const

Here is the call graph for this function:

bool C4Network2Client::SendData ( C4NetIOPacket  rPkt) const

Definition at line 108 of file C4Network2Client.cpp.

References getDataConn(), and C4Network2IOConnection::Send().

109 {
110  return getDataConn() && getDataConn()->Send(rPkt);
111 }
bool Send(const C4NetIOPacket &rPkt)
C4Network2IOConnection * getDataConn() const

Here is the call graph for this function:

bool C4Network2Client::SendMsg ( C4NetIOPacket  rPkt) const

Definition at line 103 of file C4Network2Client.cpp.

References getMsgConn(), and C4Network2IOConnection::Send().

Referenced by C4Network2::HandleStatusAck(), C4Network2::SendJoinData(), C4Network2ClientList::SendMsgToClient(), C4Network2ClientList::SendMsgToHost(), and C4Network2::UpdateChaseTarget().

104 {
105  return getMsgConn() && getMsgConn()->Send(rPkt);
106 }
C4Network2IOConnection * getMsgConn() const
bool Send(const C4NetIOPacket &rPkt)

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Network2Client::SetDataConn ( C4Network2IOConnection pConn)

Definition at line 63 of file C4Network2Client.cpp.

References C4Network2IOConnection::AddRef(), C4Network2IOConnection::DelRef(), pDataConn, pMsgConn, and SetMsgConn().

Referenced by C4Network2::HandleConnRe(), RemoveConn(), and SetMsgConn().

64 {
65  // security
66  if (pConn != pDataConn)
67  {
68  if (pDataConn) pDataConn->DelRef();
69  pDataConn = pConn;
70  pDataConn->AddRef();
71  }
72  if (!pMsgConn) SetMsgConn(pConn);
73 }
void SetMsgConn(C4Network2IOConnection *pConn)
C4Network2IOConnection * pDataConn
C4Network2IOConnection * pMsgConn

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Network2Client::SetLastActivity ( int32_t  iTick)
inline

Definition at line 111 of file C4Network2Client.h.

Referenced by C4Client::SetActivated().

111 { iLastActivity = iTick; }

Here is the caller graph for this function:

void C4Network2Client::SetMsgConn ( C4Network2IOConnection pConn)

Definition at line 51 of file C4Network2Client.cpp.

References C4Network2IOConnection::AddRef(), C4Network2IOConnection::DelRef(), pDataConn, pMsgConn, and SetDataConn().

Referenced by C4Network2::HandleConnRe(), RemoveConn(), and SetDataConn().

52 {
53  // security
54  if (pConn != pMsgConn)
55  {
56  if (pMsgConn) pMsgConn->DelRef();
57  pMsgConn = pConn;
58  pMsgConn->AddRef();
59  }
60  if (!pDataConn) SetDataConn(pConn);
61 }
void SetDataConn(C4Network2IOConnection *pConn)
C4Network2IOConnection * pDataConn
C4Network2IOConnection * pMsgConn

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Network2Client::SetStatus ( C4Network2ClientStatus  enStatus)
inline

Definition at line 110 of file C4Network2Client.h.

Referenced by C4ClientList::CtrlRemove(), C4Network2::HandleStatusAck(), C4Network2::Join(), and C4Network2::SendJoinData().

110 { eStatus = enStatus; }
C4Network2ClientStatus eStatus

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class C4Network2ClientList
friend

Definition at line 46 of file C4Network2Client.h.

Member Data Documentation

C4Network2Address C4Network2Client::Addr[C4ClientMaxAddr]
protected

Definition at line 56 of file C4Network2Client.h.

Referenced by AddAddr(), DoConnectAttempt(), hasAddr(), and SendAddresses().

int32_t C4Network2Client::AddrAttempts[C4ClientMaxAddr]
protected

Definition at line 57 of file C4Network2Client.h.

Referenced by AddAddr(), and DoConnectAttempt().

C4Network2ClientStatus C4Network2Client::eStatus
protected

Definition at line 64 of file C4Network2Client.h.

Referenced by getStatus().

int32_t C4Network2Client::iAddrCnt
protected
int32_t C4Network2Client::iLastActivity
protected

Definition at line 67 of file C4Network2Client.h.

Referenced by getLastActivity().

time_t C4Network2Client::iNextConnAttempt
protected

Definition at line 71 of file C4Network2Client.h.

Referenced by AddAddr(), DoConnectAttempt(), and getNextConnAttempt().

std::set<int> C4Network2Client::InterfaceIDs
protected

Definition at line 61 of file C4Network2Client.h.

Referenced by AddLocalAddrs(), and getInterfaceIDs().

C4Client* C4Network2Client::pClient
protected

Definition at line 53 of file C4Network2Client.h.

Referenced by DoConnectAttempt(), getClient(), and ~C4Network2Client().

C4Network2IOConnection * C4Network2Client::pDataConn
protected
class C4Network2ClientList* C4Network2Client::pParent
protected

Definition at line 75 of file C4Network2Client.h.

Referenced by AddAddr(), and SendAddresses().

class C4TableGraph* C4Network2Client::pstatPing
protected

Definition at line 78 of file C4Network2Client.h.

Referenced by ClearGraphs(), CreateGraphs(), and getStatPing().


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