diff options
Diffstat (limited to 'p2p/base/relayserver.h')
-rw-r--r-- | p2p/base/relayserver.h | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/p2p/base/relayserver.h b/p2p/base/relayserver.h index 922a256..5a5b5e2 100644 --- a/p2p/base/relayserver.h +++ b/p2p/base/relayserver.h @@ -32,10 +32,10 @@ #include <vector> #include <map> -#include "talk/base/asyncudpsocket.h" -#include "talk/base/socketaddresspair.h" -#include "talk/base/thread.h" -#include "talk/base/timeutils.h" +#include "webrtc/base/asyncudpsocket.h" +#include "webrtc/base/socketaddresspair.h" +#include "webrtc/base/thread.h" +#include "webrtc/base/timeutils.h" #include "talk/p2p/base/port.h" #include "talk/p2p/base/stun.h" @@ -46,14 +46,14 @@ class RelayServerConnection; // Relays traffic between connections to the server that are "bound" together. // All connections created with the same username/password are bound together. -class RelayServer : public talk_base::MessageHandler, +class RelayServer : public rtc::MessageHandler, public sigslot::has_slots<> { public: // Creates a server, which will use this thread to post messages to itself. - explicit RelayServer(talk_base::Thread* thread); + explicit RelayServer(rtc::Thread* thread); ~RelayServer(); - talk_base::Thread* thread() { return thread_; } + rtc::Thread* thread() { return thread_; } // Indicates whether we will print updates of the number of bindings. bool log_bindings() const { return log_bindings_; } @@ -61,38 +61,38 @@ class RelayServer : public talk_base::MessageHandler, // Updates the set of sockets that the server uses to talk to "internal" // clients. These are clients that do the "port allocations". - void AddInternalSocket(talk_base::AsyncPacketSocket* socket); - void RemoveInternalSocket(talk_base::AsyncPacketSocket* socket); + void AddInternalSocket(rtc::AsyncPacketSocket* socket); + void RemoveInternalSocket(rtc::AsyncPacketSocket* socket); // Updates the set of sockets that the server uses to talk to "external" // clients. These are the clients that do not do allocations. They do not // know that these addresses represent a relay server. - void AddExternalSocket(talk_base::AsyncPacketSocket* socket); - void RemoveExternalSocket(talk_base::AsyncPacketSocket* socket); + void AddExternalSocket(rtc::AsyncPacketSocket* socket); + void RemoveExternalSocket(rtc::AsyncPacketSocket* socket); // Starts listening for connections on this sockets. When someone // tries to connect, the connection will be accepted and a new // internal socket will be added. - void AddInternalServerSocket(talk_base::AsyncSocket* socket, + void AddInternalServerSocket(rtc::AsyncSocket* socket, cricket::ProtocolType proto); // Removes this server socket from the list. - void RemoveInternalServerSocket(talk_base::AsyncSocket* socket); + void RemoveInternalServerSocket(rtc::AsyncSocket* socket); // Methods for testing and debuging. int GetConnectionCount() const; - talk_base::SocketAddressPair GetConnection(int connection) const; - bool HasConnection(const talk_base::SocketAddress& address) const; + rtc::SocketAddressPair GetConnection(int connection) const; + bool HasConnection(const rtc::SocketAddress& address) const; private: - typedef std::vector<talk_base::AsyncPacketSocket*> SocketList; - typedef std::map<talk_base::AsyncSocket*, + typedef std::vector<rtc::AsyncPacketSocket*> SocketList; + typedef std::map<rtc::AsyncSocket*, cricket::ProtocolType> ServerSocketMap; typedef std::map<std::string, RelayServerBinding*> BindingMap; - typedef std::map<talk_base::SocketAddressPair, + typedef std::map<rtc::SocketAddressPair, RelayServerConnection*> ConnectionMap; - talk_base::Thread* thread_; + rtc::Thread* thread_; bool log_bindings_; SocketList internal_sockets_; SocketList external_sockets_; @@ -102,25 +102,25 @@ class RelayServer : public talk_base::MessageHandler, ConnectionMap connections_; // Called when a packet is received by the server on one of its sockets. - void OnInternalPacket(talk_base::AsyncPacketSocket* socket, + void OnInternalPacket(rtc::AsyncPacketSocket* socket, const char* bytes, size_t size, - const talk_base::SocketAddress& remote_addr, - const talk_base::PacketTime& packet_time); - void OnExternalPacket(talk_base::AsyncPacketSocket* socket, + const rtc::SocketAddress& remote_addr, + const rtc::PacketTime& packet_time); + void OnExternalPacket(rtc::AsyncPacketSocket* socket, const char* bytes, size_t size, - const talk_base::SocketAddress& remote_addr, - const talk_base::PacketTime& packet_time); + const rtc::SocketAddress& remote_addr, + const rtc::PacketTime& packet_time); - void OnReadEvent(talk_base::AsyncSocket* socket); + void OnReadEvent(rtc::AsyncSocket* socket); // Processes the relevant STUN request types from the client. bool HandleStun(const char* bytes, size_t size, - const talk_base::SocketAddress& remote_addr, - talk_base::AsyncPacketSocket* socket, + const rtc::SocketAddress& remote_addr, + rtc::AsyncPacketSocket* socket, std::string* username, StunMessage* msg); void HandleStunAllocate(const char* bytes, size_t size, - const talk_base::SocketAddressPair& ap, - talk_base::AsyncPacketSocket* socket); + const rtc::SocketAddressPair& ap, + rtc::AsyncPacketSocket* socket); void HandleStun(RelayServerConnection* int_conn, const char* bytes, size_t size); void HandleStunAllocate(RelayServerConnection* int_conn, @@ -133,13 +133,13 @@ class RelayServer : public talk_base::MessageHandler, void RemoveBinding(RelayServerBinding* binding); // Handle messages in our worker thread. - void OnMessage(talk_base::Message *pmsg); + void OnMessage(rtc::Message *pmsg); // Called when the timer for checking lifetime times out. void OnTimeout(RelayServerBinding* binding); // Accept connections on this server socket. - void AcceptConnection(talk_base::AsyncSocket* server_socket); + void AcceptConnection(rtc::AsyncSocket* server_socket); friend class RelayServerConnection; friend class RelayServerBinding; @@ -150,22 +150,22 @@ class RelayServer : public talk_base::MessageHandler, class RelayServerConnection { public: RelayServerConnection(RelayServerBinding* binding, - const talk_base::SocketAddressPair& addrs, - talk_base::AsyncPacketSocket* socket); + const rtc::SocketAddressPair& addrs, + rtc::AsyncPacketSocket* socket); ~RelayServerConnection(); RelayServerBinding* binding() { return binding_; } - talk_base::AsyncPacketSocket* socket() { return socket_; } + rtc::AsyncPacketSocket* socket() { return socket_; } // Returns a pair where the source is the remote address and the destination // is the local address. - const talk_base::SocketAddressPair& addr_pair() { return addr_pair_; } + const rtc::SocketAddressPair& addr_pair() { return addr_pair_; } // Sends a packet to the connected client. If an address is provided, then // we make sure the internal client receives it, wrapping if necessary. void Send(const char* data, size_t size); void Send(const char* data, size_t size, - const talk_base::SocketAddress& ext_addr); + const rtc::SocketAddress& ext_addr); // Sends a STUN message to the connected client with no wrapping. void SendStun(const StunMessage& msg); @@ -179,24 +179,24 @@ class RelayServerConnection { // Records the address that raw packets should be forwarded to (for internal // packets only; for external, we already know where they go). - const talk_base::SocketAddress& default_destination() const { + const rtc::SocketAddress& default_destination() const { return default_dest_; } - void set_default_destination(const talk_base::SocketAddress& addr) { + void set_default_destination(const rtc::SocketAddress& addr) { default_dest_ = addr; } private: RelayServerBinding* binding_; - talk_base::SocketAddressPair addr_pair_; - talk_base::AsyncPacketSocket* socket_; + rtc::SocketAddressPair addr_pair_; + rtc::AsyncPacketSocket* socket_; bool locked_; - talk_base::SocketAddress default_dest_; + rtc::SocketAddress default_dest_; }; // Records a set of internal and external connections that we relay between, // or in other words, that are "bound" together. -class RelayServerBinding : public talk_base::MessageHandler { +class RelayServerBinding : public rtc::MessageHandler { public: RelayServerBinding( RelayServer* server, const std::string& username, @@ -225,12 +225,12 @@ class RelayServerBinding : public talk_base::MessageHandler { // Determines the connection to use to send packets to or from the given // external address. RelayServerConnection* GetInternalConnection( - const talk_base::SocketAddress& ext_addr); + const rtc::SocketAddress& ext_addr); RelayServerConnection* GetExternalConnection( - const talk_base::SocketAddress& ext_addr); + const rtc::SocketAddress& ext_addr); // MessageHandler: - void OnMessage(talk_base::Message *pmsg); + void OnMessage(rtc::Message *pmsg); private: RelayServer* server_; |