[tor-commits] [pluggable-transports/snowflake-webext] 07/15: refactor: reorder lines

gitolite role git at cupani.torproject.org
Wed Nov 9 14:40:56 UTC 2022


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 833efcac57f3d3fd4dd5c22cc60777bae0ee5917
Author: WofWca <wofwca at protonmail.com>
AuthorDate: Sun Nov 6 12:41:27 2022 +0400

    refactor: reorder lines
---
 proxypair.js | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/proxypair.js b/proxypair.js
index 27e6bcc..bd128c8 100644
--- a/proxypair.js
+++ b/proxypair.js
@@ -117,23 +117,22 @@ class ProxyPair {
    * @private
    */
   prepareDataChannel(channel) {
-    // if we don't receive any keep-alive messages from the client, close the
-    // connection
-    const onStaleTimeout = () => {
-      console.log("Closing stale connection.");
-      this.flush();
-      this.close();
-    };
-    this.refreshStaleTimeout = () => {
-      clearTimeout(this.messageTimer);
-      this.messageTimer = setTimeout(onStaleTimeout, this.config.messageTimeout);
-    };
-
     channel.onopen = () => {
       log('WebRTC DataChannel opened!');
       snowflake.ui.increaseClients();
       this.counted = true;
 
+      // if we don't receive any keep-alive messages from the client, close the
+      // connection
+      const onStaleTimeout = () => {
+        console.log("Closing stale connection.");
+        this.flush();
+        this.close();
+      };
+      this.refreshStaleTimeout = () => {
+        clearTimeout(this.messageTimer);
+        this.messageTimer = setTimeout(onStaleTimeout, this.config.messageTimeout);
+      };
       this.refreshStaleTimeout();
 
       // This is the point when the WebRTC datachannel is done, so the next step

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list