@@ -16,7 +16,8 @@ chk::WsClient::WsClient()
1616 this ->webSocketPtr ->setPingInterval (30 );
1717 ix::SocketTLSOptions tlsOptions;
1818#ifndef _WIN32
19- // Currently system CAs are not supported on non-Windows platforms with mbedtls
19+ // Currently system CAs are not supported on non-Windows platforms with
20+ // mbedtls
2021 tlsOptions.caFile = " NONE" ;
2122#endif // _WIN32
2223 this ->webSocketPtr ->setTLSOptions (tlsOptions);
@@ -200,9 +201,9 @@ void WsClient::runMainLoop()
200201
201202 else {
202203 // already connected
203- this ->runServerLoop ();
204+ this ->runServerLoop ();
204205 }
205-
206+
206207 // some error happened 🙁
207208 if (this ->isDead ) {
208209 if (this ->_onDeathCallback != nullptr ) {
@@ -212,11 +213,10 @@ void WsClient::runMainLoop()
212213 } else if (this ->haveWinner ) {
213214 this ->showWinnerPopup ();
214215 }
215- // clang-format on
216216}
217217
218218/* *
219- * Try to connect to Server
219+ * Try to connect to Server.
220220 * @param address server IP or URI
221221 */
222222void WsClient::tryConnect (std::string_view address)
@@ -282,7 +282,7 @@ void WsClient::setOnReadyConnectedCallback(const onConnectedServer &callback)
282282}
283283
284284/* *
285- * Set the callback to handle starting game after signal from server
285+ * Set the callback to handle starting game after signal from server.
286286 * @param callback the callback function
287287 */
288288void WsClient::setOnReadyStartGameCallback (const onReadyStartGame &callback)
@@ -291,7 +291,7 @@ void WsClient::setOnReadyStartGameCallback(const onReadyStartGame &callback)
291291}
292292
293293/* *
294- * Set the callback to handle connection failures or server kickouts
294+ * Set the callback to handle connection failures or server kickouts.
295295 * @param callback the callback function
296296 */
297297void WsClient::setOnDeathCallback (const onDeathCallback &callback)
@@ -300,7 +300,7 @@ void WsClient::setOnDeathCallback(const onDeathCallback &callback)
300300}
301301
302302/* *
303- * Set the callback for handling Opponent moving their piece
303+ * Set the callback for handling Opponent moving their piece.
304304 * @param callback the callback function
305305 */
306306void WsClient::setOnMovePieceCallback (const onMovePieceCallback &callback)
@@ -309,7 +309,7 @@ void WsClient::setOnMovePieceCallback(const onMovePieceCallback &callback)
309309}
310310
311311/* *
312- * Set the callback for handling Opponent capturing my Piece
312+ * Set the callback for handling Opponent capturing my Piece.
313313 * @param callback the callback function
314314 */
315315void WsClient::setOnCapturePieceCallback (const onCaptureCallback &callback)
@@ -318,7 +318,7 @@ void WsClient::setOnCapturePieceCallback(const onCaptureCallback &callback)
318318}
319319
320320/* *
321- * Set the callback for handling Winner or Loser of match
321+ * Set the callback for handling Winner or Loser of match.
322322 * @param callback the callback function
323323 */
324324void WsClient::setOnWinLoseCallback (const onWinLoseCallback &callback)
@@ -327,7 +327,8 @@ void WsClient::setOnWinLoseCallback(const onWinLoseCallback &callback)
327327}
328328
329329/* *
330- * Send Protobuf response back to server
330+ * Send Protobuf response back to server.
331+ *
331332 * @param payload the request body
332333 * @return TRUE if sent successfully, else FALSE
333334 */
@@ -347,7 +348,8 @@ bool WsClient::replyServer(const chk::payload::BasePayload &payload) const
347348}
348349
349350/* *
350- * Exchange messages with the server and update the game accordingly. if any error happen, close connection
351+ * Exchange messages with the server and update the game accordingly. if any
352+ * error happens, close connection
351353 */
352354void WsClient::runServerLoop ()
353355{
@@ -360,15 +362,14 @@ void WsClient::runServerLoop()
360362 chk::payload::BasePayload basePayload;
361363 if (!basePayload.ParseFromString (msg))
362364 {
363- std::scoped_lock lg ( this ->mut ) ;
365+ std::scoped_lock lg{ this ->mut } ;
364366 this ->deathNote = " Profobuf: Could not parse payload" ;
365367 this ->isDead = true ;
366368 return ;
367369 }
368370
369371 if (basePayload.has_welcome ())
370372 {
371- /* code */
372373 chk::payload::WelcomePayload welcome = basePayload.welcome ();
373374 if (this ->_onReadyConnected != nullptr )
374375 {
@@ -414,7 +415,7 @@ void WsClient::runServerLoop()
414415 if (this ->_onWinLoseCallback != nullptr )
415416 {
416417 this ->_onWinLoseCallback (basePayload.notice ());
417- std::scoped_lock lg ( this ->mut ) ;
418+ std::scoped_lock lg{ this ->mut } ;
418419 this ->deathNote = basePayload.notice ();
419420 this ->haveWinner = true ;
420421 }
0 commit comments