[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [pluggable-transports/snowflake-webext] 10/15: refactor: simplify `pollBroker`



This is an automated email from the git hooks/post-receive script.

cohosh pushed a commit to branch main
in repository pluggable-transports/snowflake-webext.

commit 85615e0ec6696ac5c0c519380e19b8c0b398f865
Author: WofWca <wofwca@xxxxxxxxxxxxxx>
AuthorDate: Sun Nov 6 13:48:43 2022 +0400

    refactor: simplify `pollBroker`
---
 snowflake.js | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/snowflake.js b/snowflake.js
index 573b933..775fded 100644
--- a/snowflake.js
+++ b/snowflake.js
@@ -53,23 +53,21 @@ class Snowflake {
    * process. `pollBroker` automatically arranges signalling.
    */
   beginWebRTC() {
-    this.pollBroker();
+    if (this.proxyPairs.length < this.config.maxNumClients) {
+      this.pollBroker();
+    } else {
+      dbg('Polling skipped: at client capacity.');
+    }
     this.pollTimeoutId = setTimeout((() => {
       this.beginWebRTC();
     }), this.pollInterval);
   }
 
   /**
-   * Regularly poll Broker for clients to serve until this snowflake is
-   * serving at capacity, at which point stop polling.
+   * Try to get a client from the broker and start serving it upon success.
    * @private
    */
   pollBroker() {
-    // Poll broker for clients.
-    if (this.proxyPairs.length >= this.config.maxNumClients) {
-      dbg('Polling skipped: at client capacity.');
-      return;
-    }
     const pair = this.makeProxyPair();
     log('Polling broker..');
     let msg = 'Polling for client ... ';

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits