SSLClient.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright: JessMA Open Source (ldcsaa@gmail.com)
  3. *
  4. * Version : 3.6.1
  5. * Author : Bruce Liang
  6. * Website : http://www.jessma.org
  7. * Project : https://github.com/ldcsaa
  8. * Blog : http://www.cnblogs.com/ldcsaa
  9. * Wiki : http://www.oschina.net/p/hp-socket
  10. * QQ Group : 75375912
  11. *
  12. * Licensed under the Apache License, Version 2.0 (the "License");
  13. * you may not use this file except in compliance with the License.
  14. * You may obtain a copy of the License at
  15. *
  16. * http://www.apache.org/licenses/LICENSE-2.0
  17. *
  18. * Unless required by applicable law or agreed to in writing, software
  19. * distributed under the License is distributed on an "AS IS" BASIS,
  20. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. * See the License for the specific language governing permissions and
  22. * limitations under the License.
  23. */
  24. #pragma once
  25. #include "TcpClient.h"
  26. #include "SSLHelper.h"
  27. class CSSLClient : public CTcpClient
  28. {
  29. public:
  30. virtual BOOL SendPackets(const WSABUF pBuffers[], int iCount);
  31. protected:
  32. virtual EnHandleResult FireConnect();
  33. virtual EnHandleResult FireReceive(const BYTE* pData, int iLength);
  34. virtual BOOL CheckParams();
  35. virtual void PrepareStart();
  36. virtual void Reset();
  37. virtual void OnWorkerThreadEnd(DWORD dwThreadID);
  38. private:
  39. friend EnHandleResult ProcessHandShake<>(CSSLClient* pThis, CSSLClient* pSocketObj, CSSLSession* pSession);
  40. friend EnHandleResult ProcessReceive<>(CSSLClient* pThis, CSSLClient* pSocketObj, CSSLSession* pSession, const BYTE* pData, int iLength);
  41. friend BOOL ProcessSend<>(CSSLClient* pThis, CSSLClient* pSocketObj, CSSLSession* pSession, const WSABUF * pBuffers, int iCount);
  42. public:
  43. CSSLClient(ITcpClientListener* pListener)
  44. : CTcpClient(pListener)
  45. , m_sslSession (m_itPool)
  46. , m_dwMainThreadID (0)
  47. {
  48. }
  49. virtual ~CSSLClient()
  50. {
  51. Stop();
  52. }
  53. private:
  54. CSSLSession m_sslSession;
  55. DWORD m_dwMainThreadID;
  56. };