• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

NetConnection_as.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00003 //   Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 
00020 #ifndef GNASH_NETCONNECTION_H
00021 #define GNASH_NETCONNECTION_H
00022 
00023 #include "Relay.h" // for inheritance
00024 
00025 #include <vector>
00026 #include <string>
00027 #include <list>
00028 #include <memory>
00029 
00030 // Forward declarations
00031 namespace gnash {
00032     class ConnectionHandler;
00033     class as_object;
00034     class as_value;
00035     class IOChannel;
00036     struct ObjectURI;
00037 }
00038 
00039 namespace gnash {
00040 
00042 //
00045 class NetConnection_as : public ActiveRelay
00046 {
00047 public:
00048 
00049     enum StatusCode
00050     {
00051         CONNECT_FAILED,
00052         CONNECT_SUCCESS,
00053         CONNECT_CLOSED,
00054         CONNECT_REJECTED,
00055         CONNECT_APPSHUTDOWN,
00056         CALL_FAILED,
00057         CALL_BADVERSION
00058     };
00059 
00060     NetConnection_as(as_object* owner);
00061     ~NetConnection_as();
00062 
00064     virtual void update();
00065 
00067         std::string validateURL() const;
00068 
00069     void call(as_object* asCallback, const std::string& methodName,
00070             const std::vector<as_value>& args, size_t firstArg);
00071 
00073     void close();
00074 
00076     void connect(const std::string& uri);
00077 
00079     void connect();
00080 
00081     bool isConnected() const {
00082         return _isConnected;
00083     }
00084 
00085     void setURI(const std::string& uri);
00086 
00087     const std::string& getURI() const {
00088         return _uri;
00089     }
00090 
00092     void notifyStatus(StatusCode code);
00093 
00095     std::auto_ptr<IOChannel> getStream(const std::string& name);
00096 
00098     void markReachableResources() const;
00099 
00100 private:
00101 
00102     typedef std::pair<std::string, std::string> NetConnectionStatus;
00103 
00104     void getStatusCodeInfo(StatusCode code, NetConnectionStatus& info);
00105 
00107     void addToURL(const std::string& url);
00108 
00110     //
00115     std::list<ConnectionHandler*> _queuedConnections;
00116 
00118     //
00122     std::auto_ptr<ConnectionHandler> _currentConnection; 
00123 
00125     std::string _uri;
00126 
00127     bool _isConnected;
00128 
00129     void startAdvanceTimer();
00130 
00131     void stopAdvanceTimer();
00132 };
00133 
00134 void netconnection_class_init(as_object& global, const ObjectURI& uri);
00135 
00136 } // end of gnash namespace
00137 
00138 #endif
00139 
00140 // local Variables:
00141 // mode: C++
00142 // indent-tabs-mode: nil
00143 // End:

Generated on Fri Mar 16 2012 15:46:11 for Gnash by  doxygen 1.7.1