Browse Source

Added a toggle-able AutoConnect property to the JSDebugger subsystem. Made sure to turn it on when starting and off when shutting down the player.

Shaddock Heath 8 years ago
parent
commit
30eaedf160

+ 2 - 0
Source/AtomicApp/Player/IPCPlayerApp.cpp

@@ -200,6 +200,7 @@ namespace Atomic
         {
         {
             ATOMIC_LOGDEBUG("Starting JSDebugger Subsystem");
             ATOMIC_LOGDEBUG("Starting JSDebugger Subsystem");
             context_->RegisterSubsystem(new JSDebugger(context_));
             context_->RegisterSubsystem(new JSDebugger(context_));
+            context_->GetSubsystem<JSDebugger>()->AutoReconnect = true;
             context_->GetSubsystem<JSDebugger>()->Reconnect();
             context_->GetSubsystem<JSDebugger>()->Reconnect();
         }
         }
 
 
@@ -214,6 +215,7 @@ namespace Atomic
     {
     {
         if (debugPlayer_)
         if (debugPlayer_)
         {
         {
+            context_->GetSubsystem<JSDebugger>()->AutoReconnect = false;
             context_->GetSubsystem<JSDebugger>()->Shutdown();
             context_->GetSubsystem<JSDebugger>()->Shutdown();
         }
         }
 
 

+ 6 - 5
Source/AtomicJS/Javascript/JSDebugger.cpp

@@ -11,6 +11,7 @@ static duk_size_t duk_trans_socket_peek_cb(void *udata);
 static void duk_trans_socket_read_flush_cb(void *udata);
 static void duk_trans_socket_read_flush_cb(void *udata);
 static void duk_trans_socket_write_flush_cb(void *udata);
 static void duk_trans_socket_write_flush_cb(void *udata);
 static void debugger_detached (duk_context* ctx, void *udata);
 static void debugger_detached (duk_context* ctx, void *udata);
+static void duk_trans_socket_finish(void);
 
 
 namespace Atomic
 namespace Atomic
 {
 {
@@ -20,6 +21,7 @@ JSDebugger* JSDebugger::instance_ = NULL;
 JSDebugger::JSDebugger(Context* context) : Object(context)
 JSDebugger::JSDebugger(Context* context) : Object(context)
 {
 {
     instance_ = this;
     instance_ = this;
+    this->AutoReconnect = false;
 }
 }
 
 
 JSDebugger::~JSDebugger()
 JSDebugger::~JSDebugger()
@@ -29,7 +31,7 @@ JSDebugger::~JSDebugger()
 
 
 void JSDebugger::Shutdown() const
 void JSDebugger::Shutdown() const
 {
 {
-    instance_ = NULL;
+    duk_trans_socket_finish();
 }
 }
 
 
 void JSDebugger::Reconnect() const
 void JSDebugger::Reconnect() const
@@ -66,7 +68,7 @@ void JSDebugger::Reconnect() const
 
 
 static void do_reconnect()
 static void do_reconnect()
 {
 {
-    if (Atomic::JSDebugger::GetInstance())
+    if (Atomic::JSDebugger::GetInstance() && Atomic::JSDebugger::GetInstance()->AutoReconnect)
     {
     {
         Atomic::JSDebugger::GetInstance()->Reconnect();
         Atomic::JSDebugger::GetInstance()->Reconnect();
     }
     }
@@ -241,7 +243,7 @@ void duk_trans_socket_finish(void) {
         wsa_inited = 0;
         wsa_inited = 0;
     }
     }
 
 
-    // auto-restart
+    // try to auto-restart
     do_reconnect();
     do_reconnect();
 
 
 }
 }
@@ -632,8 +634,7 @@ void duk_trans_socket_finish(void) {
         server_sock = -1;
         server_sock = -1;
     }
     }
 
 
-    //
-    // auto-restart
+    // try to auto-restart
     do_reconnect();
     do_reconnect();
 }
 }
 
 

+ 3 - 0
Source/AtomicJS/Javascript/JSDebugger.h

@@ -51,6 +51,9 @@ public:
     /// Get the JSDebugger subsystem from external code
     /// Get the JSDebugger subsystem from external code
     static JSDebugger* GetInstance() { return instance_; }
     static JSDebugger* GetInstance() { return instance_; }
 
 
+    /// Automatically listen for a new connection when disconnected
+    bool AutoReconnect;
+
 private:
 private:
 
 
     static JSDebugger* instance_;
     static JSDebugger* instance_;