[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10472: More isolation: move call nu
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10472: More isolation: move call number down in the AMFQueue |
Date: |
Fri, 19 Dec 2008 18:55:44 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10472
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Fri 2008-12-19 18:55:44 +0100
message:
More isolation: move call number down in the AMFQueue
modified:
libcore/asobj/NetConnection_as.cpp
libcore/asobj/NetConnection_as.h
=== modified file 'libcore/asobj/NetConnection_as.cpp'
--- a/libcore/asobj/NetConnection_as.cpp 2008-12-18 23:44:52 +0000
+++ b/libcore/asobj/NetConnection_as.cpp 2008-12-19 17:55:44 +0000
@@ -126,7 +126,8 @@
reply(),
reply_start(0),
queued_count(0),
- ticker(0)
+ ticker(0),
+ _numCalls(0) // TODO: replace by queued count ?
{
// leave space for header
postdata.append("\000\000\000\000\000\000", 6);
@@ -464,6 +465,9 @@
}
}
+ void call(as_object* asCallback, const std::string& methodName,
+ const std::vector<as_value>& args, size_t firstArg);
+
private:
void push_amf(const SimpleBuffer &amf)
@@ -494,8 +498,80 @@
return 0;
}
}
+
+ unsigned int _numCalls;
};
+void
+AMFQueue::call(as_object* asCallback, const std::string& methodName,
+ const std::vector<as_value>& args, size_t firstArg)
+{
+ boost::scoped_ptr<SimpleBuffer> buf (new SimpleBuffer(32));
+
+ // method name
+ buf->appendNetworkShort(methodName.size());
+ buf->append(methodName.c_str(), methodName.size());
+
+ // client id (result number) as counted string
+ // the convention seems to be / followed by a unique (ascending) number
+ std::ostringstream os;
+ os << "/";
+ // Call number is not used if the callback is undefined
+ if ( asCallback )
+ {
+ os << ++_numCalls;
+ }
+ const std::string callNumberString = os.str();
+
+ buf->appendNetworkShort(callNumberString.size());
+ buf->append(callNumberString.c_str(), callNumberString.size());
+
+ size_t total_size_offset = buf->size();
+ buf->append("\000\000\000\000", 4); // total size to be filled in later
+
+ std::map<as_object*, size_t> offsetTable;
+
+ // encode array of arguments to remote method
+ buf->appendByte(amf::Element::STRICT_ARRAY_AMF0);
+ buf->appendNetworkLong(args.size()-firstArg);
+
+ VM& vm = _nc.getVM();
+
+ for (unsigned int i = firstArg; i < args.size(); ++i)
+ {
+ const as_value& arg = args[i];
+ // STRICT_ARRAY encoding is allowed for remoting
+ if ( ! arg.writeAMF0(*buf, offsetTable, vm, true) )
+ {
+ log_error("Could not serialize NetConnection.call argument %d",
+ i);
+ }
+ }
+
+ // Set the "total size" parameter.
+ *(reinterpret_cast<uint32_t*>(buf->data() + total_size_offset)) =
+ htonl(buf->size() - 4 - total_size_offset);
+
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug(_("NetConnection.call(): encoded args: %s"),
+ hexify(buf.data(), buf.size(), false));
+#endif
+
+ if (asCallback) {
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("calling enqueue with callback");
+#endif
+ enqueue(*buf, callNumberString, asCallback);
+ }
+
+ else {
+#ifdef GNASH_DEBUG_REMOTING
+ log_debug("calling enqueue without callback");
+#endif
+ enqueue(*buf);
+ }
+}
+
/// \class NetConnection
/// \brief Opens a local connection through which you can play
/// back video (FLV) files from an HTTP address or from the local file
@@ -505,7 +581,6 @@
as_object(getNetConnectionInterface()),
_callQueues(),
_currentCallQueue(0),
- _numCalls(0),
_uri(),
_isConnected(false),
_advanceTimer(0)
@@ -513,12 +588,6 @@
attachProperties(*this);
}
-unsigned int
-NetConnection_as::nextCallNumber()
-{
- return ++_numCalls;
-}
-
// extern (used by Global.cpp)
void
netconnection_class_init(as_object& global)
@@ -669,8 +738,6 @@
void
NetConnection_as::connect(const std::string& uri)
{
- _numCalls=0;
-
// Close any current connections. (why?) Because that's what happens.
close();
@@ -769,70 +836,7 @@
return;
}
- boost::scoped_ptr<SimpleBuffer> buf (new SimpleBuffer(32));
-
- // method name
- buf->appendNetworkShort(methodName.size());
- buf->append(methodName.c_str(), methodName.size());
-
- // client id (result number) as counted string
- // the convention seems to be / followed by a unique (ascending) number
- std::ostringstream os;
- os << "/";
- // Call number is not used if the callback is undefined
- if ( asCallback )
- {
- os << nextCallNumber();
- }
- const std::string callNumberString = os.str();
-
- buf->appendNetworkShort(callNumberString.size());
- buf->append(callNumberString.c_str(), callNumberString.size());
-
- size_t total_size_offset = buf->size();
- buf->append("\000\000\000\000", 4); // total size to be filled in later
-
- std::map<as_object*, size_t> offsetTable;
-
- // encode array of arguments to remote method
- buf->appendByte(amf::Element::STRICT_ARRAY_AMF0);
- buf->appendNetworkLong(args.size()-firstArg);
-
- VM& vm = getVM();
-
- for (unsigned int i = firstArg; i < args.size(); ++i)
- {
- const as_value& arg = args[i];
- // STRICT_ARRAY encoding is allowed for remoting
- if ( ! arg.writeAMF0(*buf, offsetTable, vm, true) )
- {
- log_error("Could not serialize NetConnection.call argument %d",
- i);
- }
- }
-
- // Set the "total size" parameter.
- *(reinterpret_cast<uint32_t*>(buf->data() + total_size_offset)) =
- htonl(buf->size() - 4 - total_size_offset);
-
-#ifdef GNASH_DEBUG_REMOTING
- log_debug(_("NetConnection.call(): encoded args: %s"),
- hexify(buf.data(), buf.size(), false));
-#endif
-
- if (asCallback) {
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("calling enqueue with callback");
-#endif
- _currentCallQueue->enqueue(*buf, callNumberString, asCallback);
- }
-
- else {
-#ifdef GNASH_DEBUG_REMOTING
- log_debug("calling enqueue without callback");
-#endif
- _currentCallQueue->enqueue(*buf);
- }
+ _currentCallQueue->call(asCallback, methodName, args, firstArg);
#ifdef GNASH_DEBUG_REMOTING
log_debug("called enqueue");
=== modified file 'libcore/asobj/NetConnection_as.h'
--- a/libcore/asobj/NetConnection_as.h 2008-12-18 22:39:32 +0000
+++ b/libcore/asobj/NetConnection_as.h 2008-12-19 17:55:44 +0000
@@ -90,8 +90,6 @@
/// Get an stream by name
std::auto_ptr<IOChannel> getStream(const std::string& name);
- unsigned int nextCallNumber();
-
protected:
/// Mark responders associated with remoting calls
@@ -123,12 +121,6 @@
///
std::auto_ptr<AMFQueue> _currentCallQueue;
- /// Number of calls queued for current connection
- //
- /// TODO: make it a member of AMFQueue
- ///
- unsigned int _numCalls;
-
/// the url prefix optionally passed to connect()
std::string _uri;
- [Gnash-commit] /srv/bzr/gnash/trunk r10472: More isolation: move call number down in the AMFQueue,
Sandro Santilli <=