gnash-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-dev] invoke the XMLSocket.onClose() callback


From: Ching-Yi Chan
Subject: [Gnash-dev] invoke the XMLSocket.onClose() callback
Date: Thu, 21 May 2009 11:34:49 +0800

Hi

I want to implement the `onClose' callback invoke for XMLSocket. But I have no idea how to check connection lost.

below is the poorly implementation:

address@hidden:~/temp/gnash-bzr/trunk$ bzr diff
=== modified file 'libcore/asobj/XMLSocket_as.cpp'
--- libcore/asobj/XMLSocket_as.cpp    2009-05-18 14:27:16 +0000
+++ libcore/asobj/XMLSocket_as.cpp    2009-05-21 03:20:30 +0000
@@ -93,6 +93,10 @@
         return _complete;
     }
 
+    bool timeout() const {
+        return _connectionTimeout;
+    }
+
     void setComplete() {
         _complete = true;
     }
@@ -139,7 +143,10 @@
             }
     
             // Return if timed out.
-            if (ret == 0) return;
+            if (ret == 0) {
+                _connectionTimeout = true;
+                return;
+            }
 
             const size_t bytesRead = read(fd, buf.get(), bufSize - 1);
 
@@ -210,6 +217,8 @@
 
     bool _complete;
 
+    bool _connectionTimeout;
+
     std::string _remainder;
 
     boost::scoped_ptr<boost::thread> _start;
@@ -314,6 +323,13 @@
 
     // Now the connection is established we can receive data.
     checkForIncomingData();
+
+    if(ready() &&  _connection.timeout()) {
+        log_debug(_("timeout? %s"), _connection.timeout());           
+        //callMethod(NSV::PROP_ON_CLOSE);
+        //_vm.getRoot().removeAdvanceCallback(this);
+        //return;
+    }
 }


If I know how to check connection lost, to invoke onClose callback correctly is possible.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]