Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GNASH_NETCONNECTION_H
00021 #define GNASH_NETCONNECTION_H
00022
00023 #include "Relay.h"
00024
00025 #include <vector>
00026 #include <string>
00027 #include <list>
00028 #include <memory>
00029
00030
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 }
00137
00138 #endif
00139
00140
00141
00142
00143