gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10440: NetConnection.connect() call


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10440: NetConnection.connect() calls close(). NetConnection.close() does nothing
Date: Mon, 15 Dec 2008 15:47:50 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10440
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2008-12-15 15:47:50 +0100
message:
  NetConnection.connect() calls close(). NetConnection.close() does nothing
  if not connected. Improve tests, add more notes.
modified:
  libcore/asobj/NetConnection_as.cpp
  libcore/asobj/NetConnection_as.h
  testsuite/actionscript.all/NetConnection.as
    ------------------------------------------------------------
    revno: 10434.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2008-12-15 14:05:02 +0100
    message:
      Test onStatus calls better. Start testing return from call().
    modified:
      testsuite/actionscript.all/NetConnection.as
    ------------------------------------------------------------
    revno: 10434.1.2
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2008-12-15 14:12:51 +0100
    message:
      Close existing connections. Test close() better, and drop the silly
      _inError member that was there due to misintepretation of the tests.
    modified:
      libcore/asobj/NetConnection_as.cpp
    ------------------------------------------------------------
    revno: 10434.1.3
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2008-12-15 14:13:44 +0100
    message:
      Tests.
    modified:
      testsuite/actionscript.all/NetConnection.as
    ------------------------------------------------------------
    revno: 10439.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Mon 2008-12-15 15:03:46 +0100
    message:
      More tests and improved implementation.
    modified:
      libcore/asobj/NetConnection_as.cpp
      libcore/asobj/NetConnection_as.h
      testsuite/actionscript.all/NetConnection.as
=== modified file 'libcore/asobj/NetConnection_as.cpp'
--- a/libcore/asobj/NetConnection_as.cpp        2008-12-15 09:41:52 +0000
+++ b/libcore/asobj/NetConnection_as.cpp        2008-12-15 14:03:46 +0000
@@ -510,8 +510,7 @@
     :
     as_object(getNetConnectionInterface()),
     _callQueue(0),
-    _isConnected(false),
-    _inError(false)
+    _isConnected(false)
 {
     attachProperties(*this);
 }
@@ -644,8 +643,9 @@
 void
 NetConnection_as::connect()
 {
+    // Close any current connections.
+    close();
     _isConnected = true;
-    _inError = false;
     notifyStatus(CONNECT_SUCCESS);
 }
 
@@ -653,6 +653,8 @@
 void
 NetConnection_as::connect(const std::string& /*uri*/)
 {
+    // Close any current connections.
+    close();
 
     // FIXME: We should attempt a connection here (this is called when an
     // argument is passed to NetConnection.connect(url).
@@ -667,7 +669,6 @@
     //    and fails immediately.
     // TODO: modify validateURL for doing this.
     _isConnected = false;
-    _inError = true;
     notifyStatus(CONNECT_FAILED);
 }
 
@@ -677,13 +678,13 @@
 void
 NetConnection_as::close()
 {
+    if (!_isConnected) return;
+
     /// TODO: what should actually happen here? Should an attached
     /// NetStream object be interrupted?
     _isConnected = false;
 
-    // If a previous connect() attempt failed, close() will not send
-    // an onStatus event.
-    if (!_inError) notifyStatus(CONNECT_CLOSED);
+    notifyStatus(CONNECT_CLOSED);
 }
 
 
@@ -711,19 +712,16 @@
     // not connected).
     URL url(validateURL());
 
-    // FIXME check if it's possible for the URL of a NetConnection
-    // to change between call()s
+    // The URL depends on the URL passed to NetConnection.connect();
     if (!_callQueue.get()) {
         _callQueue.reset(new AMFQueue(*this, url));
     }
 
     if (asCallback) {
-        //boost::intrusive_ptr<as_object> intrusive_callback(asCallback);
 #ifdef GNASH_DEBUG_REMOTING
         log_debug("calling enqueue with callback");
 #endif
         _callQueue->enqueue(buf, callNumber, asCallback);
-        //? delete asCallback;
     }
     
     else {
@@ -746,7 +744,10 @@
     StreamProvider& streamProvider = ri.streamProvider();
 
     // Construct URL with base URL (assuming not connected to RTMP server..)
-    // TODO: use getURI to figure the base url, if any
+    // TODO: For RTMP return the named stream from an existing RTMP connection.
+    // If name is a full or relative URL passed from NetStream.play(), it
+    // must be constructed against the base URL, not the NetConnection uri,
+    // which should always be null in this case.
     return streamProvider.getStream(URL(name, ri.baseURL()));
 
 }

=== modified file 'libcore/asobj/NetConnection_as.h'
--- a/libcore/asobj/NetConnection_as.h  2008-12-13 10:59:04 +0000
+++ b/libcore/asobj/NetConnection_as.h  2008-12-15 14:03:46 +0000
@@ -107,9 +107,6 @@
 
     bool _isConnected;
 
-    bool _inError;
-
-
 };
 
 void netconnection_class_init(as_object& global);

=== modified file 'testsuite/actionscript.all/NetConnection.as'
--- a/testsuite/actionscript.all/NetConnection.as       2008-12-15 09:26:01 
+0000
+++ b/testsuite/actionscript.all/NetConnection.as       2008-12-15 14:03:46 
+0000
@@ -70,9 +70,11 @@
        pass("NetConnection::connect() initialized correctly");
 }
 
+statuses = new Array;
 tmp.onStatus = function(info) {
     result = info.code;
     level = info.level;
+    statuses.push(info.code);
 };
 
 result = "";
@@ -112,6 +114,8 @@
 tmp.uri = 6;
 check_equals(tmp.uri, "null");
 
+
+statuses = new Array();
 ret = tmp.connect(1);
 check_equals(ret, false);
 check_equals(tmp.isConnected, false);
@@ -119,7 +123,10 @@
 check_equals(level, "error");
 check_equals(typeof(tmp.uri), "string");
 check_equals(tmp.uri, "1");
+check_equals(statuses.toString(),
+            "NetConnection.Connect.Closed,NetConnection.Connect.Failed");
 
+statuses = new Array();
 ret = tmp.connect("string");
 check_equals(ret, false);
 check_equals(tmp.isConnected, false);
@@ -127,6 +134,8 @@
 check_equals(level, "error");
 check_equals(typeof(tmp.uri), "string");
 check_equals(tmp.uri, "string");
+check_equals(statuses.toString(),
+            "NetConnection.Connect.Failed");
 
 ret = tmp.connect(undefined);
 
@@ -146,12 +155,21 @@
 check_equals(tmp.uri, "");
 #endif
 
+statuses = new Array;
 ret = tmp.connect(null);
 check_equals(ret, true);
 check_equals(tmp.isConnected, true);
 check_equals(result, "NetConnection.Connect.Success");
 check_equals(level, "status");
 
+// This depends on whether isConnected() was true or not.
+#if OUTPUT_VERSION > 6
+check_equals(statuses.toString(),
+        "NetConnection.Connect.Closed,NetConnection.Connect.Success");
+#else
+check_equals(statuses.toString(),
+        "NetConnection.Connect.Success");
+#endif
 // The pp and Gnash sandboxes behave differently. The pp rejects any
 // network connection from filesystem-loaded SWFs unless the SWF location
 // is added to the player configuration file. This server is blacklisted
@@ -165,6 +183,26 @@
 check_equals(result, "NetConnection.Connect.Failed");
 check_equals(level, "error");
 
+
+// Close() doesn't reset uri
+tmp.close();
+check_equals(tmp.uri, "http://www.blacklistedserver.org";);
+
+// Test call()
+
+statuses = new Array;
+// No Call onStatus event when not connected.
+ret = tmp.call("o");
+check_equals(ret, undefined);
+check_equals(statuses.length, 0);
+
+// No Call onStatus event when connected with null.
+tmp.connect(null);
+ret = tmp.call("o");
+check_equals(ret, undefined);
+check_equals(statuses.length, 1);
+check_equals(result, "NetConnection.Connect.Success");
+
 // Check onStatus object.
 
 nc = new NetConnection;
@@ -192,6 +230,7 @@
 nc.onStatus = function(info) {
     result = info.code;
     level = info.level;
+    statuses.push(info.code);
 };
 
 // Sanity check
@@ -217,6 +256,7 @@
 
 // NetConnection close
 
+statuses = new Array;
 check(nc.isConnected);
 ret = nc.close();
 check_equals(nc.isConnected, false);
@@ -232,6 +272,9 @@
 check_equals(result, "NetConnection.Connect.Closed");
 check_equals(level, "status");
 
+// Only called once
+check_equals(statuses.toString(), "NetConnection.Connect.Closed");
+
 nc.connect(1);
 check_equals(nc.isConnected, false);
 check_equals(typeof(ret), "undefined");
@@ -245,7 +288,7 @@
 check_equals(result, "NetConnection.Connect.Failed");
 check_equals(level, "error");
 
-check_totals(107);
+check_totals(117);
 
 
 


reply via email to

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