Gnash  0.8.11dev
NetConnection_as.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef GNASH_NETCONNECTION_H
20 #define GNASH_NETCONNECTION_H
21 
22 
23 #include <vector>
24 #include <string>
25 #include <list>
26 #include <memory>
27 #include <boost/shared_ptr.hpp>
28 
29 #include "Relay.h"
30 
31 // Forward declarations
32 namespace gnash {
33  class Connection;
34  class as_object;
35  class as_value;
36  class IOChannel;
37  struct ObjectURI;
38 }
39 
40 namespace gnash {
41 
43 //
47 {
48 public:
49 
51  {
59  };
60 
62 
63  virtual ~NetConnection_as();
64 
66  virtual void update();
67 
69  std::string validateURL() const;
70 
71  void call(as_object* asCallback, const std::string& methodName,
72  const std::vector<as_value>& args);
73 
75  void close();
76 
78  //
81  bool connect(const std::string& uri);
82 
84  //
87  void connect();
88 
89  void setConnected() {
90  _isConnected = true;
91  }
92 
93  bool isConnected() const {
94  return _isConnected;
95  }
96 
97  void setURI(const std::string& uri);
98 
99  const std::string& getURI() const {
100  return _uri;
101  }
102 
105 
107  std::auto_ptr<IOChannel> getStream(const std::string& name);
108 
110  void markReachableResources() const;
111 
112 private:
113 
114  bool isRTMP();
115 
116  void createStream(as_object* asCallback);
117 
119  void addToURL(const std::string& url);
120 
121  typedef std::list<boost::shared_ptr<Connection> > Connections;
122 
124  //
129  Connections _oldConnections;
130 
132  std::auto_ptr<Connection> _currentConnection;
133 
135  std::string _uri;
136 
137  bool _isConnected;
138 
139  void startAdvanceTimer();
140 
141  void stopAdvanceTimer();
142 };
143 
144 void netconnection_class_init(as_object& global, const ObjectURI& uri);
145 
146 } // end of gnash namespace
147 
148 #endif
149 
150 // local Variables:
151 // mode: C++
152 // indent-tabs-mode: nil
153 // End: