summaryrefslogtreecommitdiffstats
path: root/remoting/jingle_glue/jingle_signaling_connector.h
blob: c45c269aca6f04d501aed405069a07aedf92d5c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef REMOTING_JINGLE_GLUE_JINGLE_SIGNALING_CONNECTOR_H_
#define REMOTING_JINGLE_GLUE_JINGLE_SIGNALING_CONNECTOR_H_

#include <map>

#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "remoting/jingle_glue/signal_strategy.h"
#include "third_party/libjingle/source/talk/base/sigslot.h"

namespace buzz {
class XmlElement;
}  // namespace buzz

namespace cricket {
class SessionManager;
}  // namespace cricket

namespace remoting {

class JavascriptIqRequest;

// This class handles proxying the Jingle establishment messages between the
// client and the server when proxying XMPP through Javascript.
//
// The |request| object is used to send and receive IQ stanzas from the XMPP
// network.  The |session_manager| controls sending and receiving of stanzas
// after Run() is invoked.
//
// This class is not threadsafe, and should only be used on the thread it is
// created on.
//
// TODO(sergeyu): This class should not depend on JavascriptIqRequest:
// it should work with SignalStrategy instead.
class JingleSignalingConnector : public SignalStrategy::Listener,
                                 public sigslot::has_slots<> {
 public:
  JingleSignalingConnector(SignalStrategy* signal_strategy,
                           cricket::SessionManager* session_manager);
  virtual ~JingleSignalingConnector();

  // SignalStrategy::Listener interface.
  virtual bool OnIncomingStanza(const buzz::XmlElement* stanza) OVERRIDE;

 private:
  typedef std::map<std::string, buzz::XmlElement*> IqRequestsMap;

  void OnOutgoingMessage(cricket::SessionManager* manager,
                         const buzz::XmlElement* stanza);

  SignalStrategy* signal_strategy_;
  cricket::SessionManager* session_manager_;
  IqRequestsMap pending_requests_;

  DISALLOW_COPY_AND_ASSIGN(JingleSignalingConnector);
};

}  // namespace remoting

#endif  // REMOTING_JINGLE_GLUE_JINGLE_SIGNALING_CONNECTOR_H_