MCPcopy Create free account
hub / github.com/AlSch092/UltimateAntiCheat / ProcessRequests

Method ProcessRequests

Network/NetClient.cpp:138–206  ·  view source on GitHub ↗

ProcessRequests - reads packet sent from the server in a loop */

Source from the content-addressed store, hash-verified

136 ProcessRequests - reads packet sent from the server in a loop
137*/
138void NetClient::ProcessRequests(__in LPVOID Param)
139{
140 if (Param == nullptr)
141 {
142 Logger::logf(Info, "NetClient class pointer was nullptr @ ProcessRequests");
143 return;
144 }
145
146 bool receiving = true;
147 const int ms_between_loops = 1000;
148 unsigned char recvBuf[DEFAULT_RECV_LENGTH] = { 0 };
149
150 Logger::logf(Info, "Started thread on NetClient::ProcessRequests with id: %d", GetCurrentThreadId());
151
152 NetClient* Client = reinterpret_cast<NetClient*>(Param);
153
154 if (Client == nullptr)
155 {
156 Logger::logf(Err, "Client was NULL @ NetClient::ProcessRequests");
157 receiving = false; //todo: send signals to rest of anticheat to shutdown
158 goto end;
159 }
160
161 while (receiving)
162 {
163 if (Client->GetRecvThread()->IsShutdownSignalled())
164 {
165 goto end;
166 }
167
168 SOCKET s = Client->GetClientSocket();
169
170 if (s)
171 {
172 int bytesIn = 0;
173
174 {
175 std::lock_guard<std::mutex> lock(Client->RecvPacketMutex);
176 bytesIn = recv(s, (char*)recvBuf, DEFAULT_RECV_LENGTH, 0);
177 }
178
179 if (bytesIn == 0)
180 continue;
181
182 if (bytesIn != SOCKET_ERROR)
183 {
184 Client->CipherData(recvBuf, bytesIn); //decrypt buffer
185
186 PacketReader* p = new PacketReader(recvBuf, bytesIn);
187 Client->HandleInboundPacket(p);
188 delete p;
189 }
190 else
191 receiving = false;
192 }
193 else if(s == SOCKET_ERROR)
194 {
195 Logger::logf(Err, "Socket error @ NetClient::ProcessRequests");

Callers

nothing calls this directly

Calls 5

IsShutdownSignalledMethod · 0.80
GetRecvThreadMethod · 0.80
GetClientSocketMethod · 0.80
CipherDataMethod · 0.80
HandleInboundPacketMethod · 0.80

Tested by

no test coverage detected