Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : 6 : #ifndef XMPP_XMPP_CONNECTION_MANAGER_H 7 : #define XMPP_XMPP_CONNECTION_MANAGER_H 8 : 9 : #include <mutex> 10 : 11 : #include "base/queue_task.h" 12 : #include "io/ssl_server.h" 13 : 14 : class LifetimeActor; 15 : class XmppSession; 16 : 17 : // 18 : // Common class to represent XmppClient and XmppServer 19 : // 20 : class XmppConnectionManager : public SslServer { 21 : public: 22 : XmppConnectionManager(EventManager *evm, 23 : boost::asio::ssl::context::method m, 24 : bool ssl_enabled, bool ssl_handshake_delayed); 25 : 26 : void Shutdown(); 27 : void EnqueueSession(XmppSession *session); 28 : size_t GetSessionQueueSize() const; 29 : virtual LifetimeActor *deleter() = 0; 30 15771 : std::mutex &mutex() const { return mutex_; } 31 : 32 : private: 33 : bool DequeueSession(TcpSessionPtr tcp_session); 34 : void WorkQueueExitCallback(bool done); 35 : 36 : WorkQueue<TcpSessionPtr> session_queue_; 37 : mutable std::mutex mutex_; 38 : 39 : DISALLOW_COPY_AND_ASSIGN(XmppConnectionManager); 40 : }; 41 : 42 : #endif // XMPP_XMPP_CONNECTION_MANAGER_H