OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_SIGNALING_SIGNAL_STRATEGY_H_ | 5 #ifndef REMOTING_SIGNALING_SIGNAL_STRATEGY_H_ |
6 #define REMOTING_SIGNALING_SIGNAL_STRATEGY_H_ | 6 #define REMOTING_SIGNALING_SIGNAL_STRATEGY_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 | 12 |
13 namespace buzz { | 13 namespace buzz { |
14 class XmlElement; | 14 class XmlElement; |
15 } // namespace buzz | 15 } // namespace buzz |
16 | 16 |
17 namespace remoting { | 17 namespace remoting { |
18 | 18 |
| 19 class SignalingAddress; |
| 20 |
19 class SignalStrategy { | 21 class SignalStrategy { |
20 public: | 22 public: |
21 enum State { | 23 enum State { |
22 // Connection is being established. | 24 // Connection is being established. |
23 CONNECTING, | 25 CONNECTING, |
24 | 26 |
25 // Signalling is connected. | 27 // Signalling is connected. |
26 CONNECTED, | 28 CONNECTED, |
27 | 29 |
28 // Connection is closed due to an error or because Disconnect() | 30 // Connection is closed due to an error or because Disconnect() |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // Disconnects current connection if connected. Triggers CLOSED | 70 // Disconnects current connection if connected. Triggers CLOSED |
69 // notification. | 71 // notification. |
70 virtual void Disconnect() = 0; | 72 virtual void Disconnect() = 0; |
71 | 73 |
72 // Returns current state. | 74 // Returns current state. |
73 virtual State GetState() const = 0; | 75 virtual State GetState() const = 0; |
74 | 76 |
75 // Returns the last error. Set when state changes to DISCONNECT. | 77 // Returns the last error. Set when state changes to DISCONNECT. |
76 virtual Error GetError() const = 0; | 78 virtual Error GetError() const = 0; |
77 | 79 |
78 // Returns local JID or an empty string when not connected. | 80 // Local address. An empty value is returned when not connected. |
79 virtual std::string GetLocalJid() const = 0; | 81 virtual const SignalingAddress& GetLocalAddress() const = 0; |
80 | 82 |
81 // Add a |listener| that can listen to all incoming | 83 // Add a |listener| that can listen to all incoming |
82 // messages. Doesn't take ownership of the |listener|. All listeners | 84 // messages. Doesn't take ownership of the |listener|. All listeners |
83 // must be removed before this object is destroyed. | 85 // must be removed before this object is destroyed. |
84 virtual void AddListener(Listener* listener) = 0; | 86 virtual void AddListener(Listener* listener) = 0; |
85 | 87 |
86 // Remove a |listener| previously added with AddListener(). | 88 // Remove a |listener| previously added with AddListener(). |
87 virtual void RemoveListener(Listener* listener) = 0; | 89 virtual void RemoveListener(Listener* listener) = 0; |
88 | 90 |
89 // Sends a raw XMPP stanza. Returns false if the stanza couldn't be send. | 91 // Sends a raw XMPP stanza. Returns false if the stanza couldn't be send. |
90 virtual bool SendStanza(std::unique_ptr<buzz::XmlElement> stanza) = 0; | 92 virtual bool SendStanza(std::unique_ptr<buzz::XmlElement> stanza) = 0; |
91 | 93 |
92 // Returns new ID that should be used for the next outgoing IQ | 94 // Returns new ID that should be used for the next outgoing IQ |
93 // request. | 95 // request. |
94 virtual std::string GetNextId() = 0; | 96 virtual std::string GetNextId() = 0; |
95 | 97 |
96 private: | 98 private: |
97 DISALLOW_COPY_AND_ASSIGN(SignalStrategy); | 99 DISALLOW_COPY_AND_ASSIGN(SignalStrategy); |
98 }; | 100 }; |
99 | 101 |
100 } // namespace remoting | 102 } // namespace remoting |
101 | 103 |
102 #endif // REMOTING_SIGNALING_SIGNAL_STRATEGY_H_ | 104 #endif // REMOTING_SIGNALING_SIGNAL_STRATEGY_H_ |
OLD | NEW |