2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef WEBRTC_P2P_CLIENT_SESSIONMANAGERTASK_H_
12 #define WEBRTC_P2P_CLIENT_SESSIONMANAGERTASK_H_
14 #include "webrtc/p2p/base/sessionmanager.h"
15 #include "webrtc/p2p/client/sessionsendtask.h"
16 #include "webrtc/libjingle/xmpp/xmppengine.h"
17 #include "webrtc/libjingle/xmpp/xmpptask.h"
21 // This class handles sending and receiving XMPP messages on behalf of the
22 // SessionManager. The sending part is handed over to SessionSendTask.
24 class SessionManagerTask : public buzz::XmppTask {
26 SessionManagerTask(buzz::XmppTaskParentInterface* parent,
27 SessionManager* session_manager)
28 : buzz::XmppTask(parent, buzz::XmppEngine::HL_SINGLE),
29 session_manager_(session_manager) {
32 ~SessionManagerTask() {
35 // Turns on simple support for sending messages, using SessionSendTask.
36 void EnableOutgoingMessages() {
37 session_manager_->SignalOutgoingMessage.connect(
38 this, &SessionManagerTask::OnOutgoingMessage);
39 session_manager_->SignalRequestSignaling.connect(
40 session_manager_, &SessionManager::OnSignalingReady);
43 virtual int ProcessStart() {
44 const buzz::XmlElement *stanza = NextStanza();
47 session_manager_->OnIncomingMessage(stanza);
52 virtual bool HandleStanza(const buzz::XmlElement *stanza) {
53 if (!session_manager_->IsSessionMessage(stanza))
55 // Responses are handled by the SessionSendTask that sent the request.
56 //if (stanza->Attr(buzz::QN_TYPE) != buzz::STR_SET)
63 void OnOutgoingMessage(SessionManager* manager,
64 const buzz::XmlElement* stanza) {
65 cricket::SessionSendTask* sender =
66 new cricket::SessionSendTask(parent_, session_manager_);
71 SessionManager* session_manager_;
74 } // namespace cricket
76 #endif // WEBRTC_P2P_CLIENT_SESSIONMANAGERTASK_H_