Conflicts:

src/lib/client/Client.cpp
	src/lib/net/TCPSocketFactory.cpp
This commit is contained in:
Jerry (Xinyu Hou)
2016-08-24 15:14:12 +01:00
committed by Andrew Nelless
parent e32402b5c6
commit 95464d97cf
7 changed files with 69 additions and 12 deletions

View File

@@ -18,6 +18,7 @@
#include "SecureSocket.h"
#include "net/TSocketMultiplexerMethodJob.h"
#include "base/TMethodEventJob.h"
#include "net/TCPSocket.h"
#include "mt/Lock.h"
#include "arch/XArch.h"
@@ -100,6 +101,29 @@ SecureSocket::close()
TCPSocket::close();
}
void
SecureSocket::connect(const NetworkAddress& addr)
{
m_events->adoptHandler(m_events->forIDataSocket().connected(),
getEventTarget(),
new TMethodEventJob<SecureSocket>(this,
&SecureSocket::handleTCPConnected));
TCPSocket::connect(addr);
}
ISocketMultiplexerJob*
SecureSocket::newJob()
{
// after TCP connection is established, SecureSocket will pick up
// connected event and do secureConnect
if (m_connected && !m_secureReady) {
return NULL;
}
return TCPSocket::newJob();
}
void
SecureSocket::secureConnect()
{
@@ -609,6 +633,7 @@ SecureSocket::serviceConnect(ISocketMultiplexerJob* job,
// If status > 0, success
if (status > 0) {
sendEvent(m_events->forIDataSocket().secureConnected());
return newJob();
}
@@ -714,3 +739,9 @@ SecureSocket::showSecureConnectInfo()
}
return;
}
void
SecureSocket::handleTCPConnected(const Event& event, void*)
{
secureConnect();
}

View File

@@ -41,6 +41,11 @@ public:
// ISocket overrides
void close();
// IDataSocket overrides
virtual void connect(const NetworkAddress&);
ISocketMultiplexerJob*
newJob();
void secureConnect();
void secureAccept();
bool isReady() const { return m_secureReady; }
@@ -80,6 +85,8 @@ private:
void showSecureConnectInfo();
void showSecureLibInfo();
void showSecureCipherInfo();
void handleTCPConnected(const Event& event, void*);
private:
Ssl* m_ssl;