OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 // connection is valid, implementing XEP-0199. | 21 // connection is valid, implementing XEP-0199. |
22 // | 22 // |
23 // This is especially useful on cellular networks because: | 23 // This is especially useful on cellular networks because: |
24 // 1. It keeps the connections alive through the cellular network's NATs or | 24 // 1. It keeps the connections alive through the cellular network's NATs or |
25 // proxies. | 25 // proxies. |
26 // 2. It detects when the server has crashed or any other case in which the | 26 // 2. It detects when the server has crashed or any other case in which the |
27 // connection has broken without a fin or reset packet being sent to us. | 27 // connection has broken without a fin or reset packet being sent to us. |
28 class PingTask : public buzz::XmppTask, private rtc::MessageHandler { | 28 class PingTask : public buzz::XmppTask, private rtc::MessageHandler { |
29 public: | 29 public: |
30 PingTask(buzz::XmppTaskParentInterface* parent, | 30 PingTask(buzz::XmppTaskParentInterface* parent, |
31 rtc::MessageQueue* message_queue, uint32 ping_period_millis, | 31 rtc::MessageQueue* message_queue, |
32 uint32 ping_timeout_millis); | 32 uint32_t ping_period_millis, |
| 33 uint32_t ping_timeout_millis); |
33 | 34 |
34 virtual bool HandleStanza(const buzz::XmlElement* stanza); | 35 virtual bool HandleStanza(const buzz::XmlElement* stanza); |
35 virtual int ProcessStart(); | 36 virtual int ProcessStart(); |
36 | 37 |
37 // Raised if there is no response to a ping within ping_timeout_millis. | 38 // Raised if there is no response to a ping within ping_timeout_millis. |
38 // The task is automatically aborted after a timeout. | 39 // The task is automatically aborted after a timeout. |
39 sigslot::signal0<> SignalTimeout; | 40 sigslot::signal0<> SignalTimeout; |
40 | 41 |
41 private: | 42 private: |
42 // Implementation of MessageHandler. | 43 // Implementation of MessageHandler. |
43 virtual void OnMessage(rtc::Message* msg); | 44 virtual void OnMessage(rtc::Message* msg); |
44 | 45 |
45 rtc::MessageQueue* message_queue_; | 46 rtc::MessageQueue* message_queue_; |
46 uint32 ping_period_millis_; | 47 uint32_t ping_period_millis_; |
47 uint32 ping_timeout_millis_; | 48 uint32_t ping_timeout_millis_; |
48 uint32 next_ping_time_; | 49 uint32_t next_ping_time_; |
49 uint32 ping_response_deadline_; // 0 if the response has been received | 50 uint32_t ping_response_deadline_; // 0 if the response has been received |
50 }; | 51 }; |
51 | 52 |
52 } // namespace buzz | 53 } // namespace buzz |
53 | 54 |
54 #endif // WEBRTC_LIBJINGLE_XMPP_PINGTASK_H_ | 55 #endif // WEBRTC_LIBJINGLE_XMPP_PINGTASK_H_ |
OLD | NEW |