_IpEpEngineEvents_CP.h
author Volker Birk <vb@pep-project.org>
Wed, 11 May 2016 16:35:59 +0200
changeset 72 6afc06b8c3c5
parent 0 0aa9866d751c
child 75 65a253e12538
permissions -rw-r--r--
adding events and ConnectionPoint
vb@0
     1
#pragma once
vb@0
     2
vb@72
     3
template<class T>
vb@72
     4
class CProxy_IpEpEngineEvents :
vb@72
     5
	public ATL::IConnectionPointImpl<T, &__uuidof(_IpEpEngineEvents)>
vb@72
     6
{
vb@72
     7
public:
vb@72
     8
	HRESULT Fire_messageToSend(text_message * msg)
vb@72
     9
	{
vb@72
    10
		HRESULT hr = S_OK;
vb@72
    11
		T * pThis = static_cast<T *>(this);
vb@72
    12
		int cConnections = m_vec.GetSize();
vb@0
    13
vb@72
    14
		for (int iConnection = 0; iConnection < cConnections; iConnection++)
vb@72
    15
		{
vb@72
    16
			pThis->Lock();
vb@72
    17
			CComPtr<IUnknown> punkConnection = m_vec.GetAt(iConnection);
vb@72
    18
			pThis->Unlock();
vb@72
    19
vb@72
    20
			_IpEpEngineEvents * pConnection = static_cast<_IpEpEngineEvents *>(punkConnection.p);
vb@72
    21
vb@72
    22
			if (pConnection)
vb@72
    23
			{
vb@72
    24
				hr = pConnection->messageToSend(msg);
vb@72
    25
			}
vb@72
    26
		}
vb@72
    27
		return hr;
vb@72
    28
	}
vb@72
    29
	HRESULT Fire_showHandshake(pEp_identity_s * self, pEp_identity_s * partner, sync_handshake_result * result)
vb@72
    30
	{
vb@72
    31
		HRESULT hr = S_OK;
vb@72
    32
		T * pThis = static_cast<T *>(this);
vb@72
    33
		int cConnections = m_vec.GetSize();
vb@72
    34
vb@72
    35
		for (int iConnection = 0; iConnection < cConnections; iConnection++)
vb@72
    36
		{
vb@72
    37
			pThis->Lock();
vb@72
    38
			CComPtr<IUnknown> punkConnection = m_vec.GetAt(iConnection);
vb@72
    39
			pThis->Unlock();
vb@72
    40
vb@72
    41
			_IpEpEngineEvents * pConnection = static_cast<_IpEpEngineEvents *>(punkConnection.p);
vb@72
    42
vb@72
    43
			if (pConnection)
vb@72
    44
			{
vb@72
    45
				hr = pConnection->showHandshake(self, partner, result);
vb@72
    46
			}
vb@72
    47
		}
vb@72
    48
		return hr;
vb@72
    49
	}
vb@0
    50
};
vb@72
    51