27#define RESIPROCATE_SUBSYSTEM ReconSubsystem::RECON
34 AppDialogSet(conversationManager.getUserAgent()->getDialogUsageManager()),
35 mDum(conversationManager.getUserAgent()->getDialogUsageManager()),
36 mNumOutstandingSends(0),
37 mDelayedDestroyPending(false)
39 InfoLog(<<
"RemoteIMPagerParticipant created, handle=" <<
mHandle);
40 mConversationProfile =
nullptr;
45 const NameAddr& destination, std::shared_ptr<ConversationProfile> conversationProfile) :
48 AppDialogSet(conversationManager.getUserAgent()->getDialogUsageManager()),
49 mDum(conversationManager.getUserAgent()->getDialogUsageManager())
51 InfoLog(<<
"RemoteIMPagerParticipant created, handle=" <<
mHandle);
52 mRemoteUri = destination;
55 if (conversationProfile ==
nullptr)
61 mConversationProfile = conversationProfile;
64 mLocalAorNoPort = mConversationProfile->getDefaultFrom().uri().getAorNoPort();
76 InfoLog(<<
"RemoteIMPagerParticipant destroyed, handle=" <<
mHandle);
82 if (mNumOutstandingSends > 0)
85 mDelayedDestroyPending =
true;
91 if (mServerPagerMessageHandle.
isValid())
93 mServerPagerMessageHandle->send(mServerPagerMessageHandle->reject(410 ));
95 if (mClientPagerMessageHandle.
isValid())
97 mClientPagerMessageHandle->end();
106 WarningLog(<<
"RemoteIMPagerParticipant::destroyParticipant exception: " << e);
110 WarningLog(<<
"RemoteIMPagerParticipant::destroyParticipant unknown exception");
117 if (!mClientPagerMessageHandle.
isValid())
120 mClientPagerMessageHandle = mDum.
makePagerMessage(mRemoteUri, mConversationProfile,
this);
122 mClientPagerMessageHandle->page(std::move(contents));
123 mNumOutstandingSends++;
131 if (mServerPagerMessageHandle.
isValid())
133 mServerPagerMessageHandle->send(mServerPagerMessageHandle->accept());
142 relayInstantMessageToConversations(mInitialIncomingMessage);
148 WarningLog(<<
"RemoteIMPagerParticipant::accept exception: " << e);
152 WarningLog(<<
"RemoteIMPagerParticipant::accept unknown exception");
161 if (mServerPagerMessageHandle.
isValid())
163 mServerPagerMessageHandle->send(mServerPagerMessageHandle->reject(rejectCode));
170 WarningLog(<<
"RemoteIMPagerParticipant::reject exception: " << e);
174 WarningLog(<<
"RemoteIMPagerParticipant::reject unknown exception");
183 bool matches = mLocalAorNoPort == messageToAor && mRemoteAorNoPort == messageFromAor;
185 DebugLog(<<
"RemoteIMPagerParticipant::doesMessageMatch: partHandle=" <<
mHandle <<
", LocalAor=" << mLocalAorNoPort <<
", msgTo=" << messageToAor <<
", RemoteAor=" << mRemoteAorNoPort <<
", msgFrom=" << messageFromAor << (matches ?
" - YES" :
" - NO"));
201 if (mNumOutstandingSends > 0)
203 mNumOutstandingSends--;
205 if (mDelayedDestroyPending && mNumOutstandingSends == 0)
208 mDelayedDestroyPending =
false;
224 if (mNumOutstandingSends > 0)
226 mNumOutstandingSends--;
234 if (mDelayedDestroyPending)
237 mNumOutstandingSends = 0;
241 mDelayedDestroyPending =
false;
254 InfoLog(<<
"RemoteIMPagerParticipant::onMessageArrived: handle=" <<
mHandle <<
", " << msg.
brief());
256 mServerPagerMessageHandle = h;
260 if (mRemoteDisplayName.
empty())
262 mRemoteDisplayName = msg.
header(h_From).displayName();
263 if (mRemoteDisplayName.
empty())
270 if (mConversationProfile ==
nullptr)
273 mConversationProfile = std::dynamic_pointer_cast<ConversationProfile>(h->getUserProfile());
275 mInitialIncomingMessage = msg;
286 h->send(h->accept());
295 relayInstantMessageToConversations(msg);
301RemoteIMPagerParticipant::relayInstantMessageToConversations(
const SipMessage& msg)
306 ConversationMap::iterator it;
309 it->second->relayInstantMessageToRemoteParticipants(
mHandle, mRemoteDisplayName, msg);
#define WarningLog(args_)
#define resip_assert(x)
This file needs to work for both C and C++ code.
This class is one of two main classes of concern to an application using the UserAgent library.
virtual void onParticipantSendIMFailure(ParticipantHandle partHandle, const resip::SipMessage &status, std::unique_ptr< resip::Contents > contents)
Notifies an application that a send IM call has failed.
UserAgent * getUserAgent()
virtual void onIncomingIMPagerParticipant(ParticipantHandle partHandle, const resip::SipMessage &msg, ConversationProfile &conversationProfile)
Notifies an application about a new remote IM pager mode participant that has sent a message.
virtual bool onReceiveIMFromParticipant(ParticipantHandle partHandle, const resip::SipMessage &msg)
Notifies an application about a subsequent message from remote and existing IM participant.
This class represents base functionality for a participant that supports IMs.
This is the base class for a RemoteParticipant, LocalParticipant and a MediaResourceParticipant.
ConversationMap mConversations
virtual void unregisterFromAllConversations()
ParticipantHandle mHandle
ConversationManager & mConversationManager
std::shared_ptr< ConversationProfile > getDefaultOutgoingConversationProfile()
The abstract base-class for all exceptions thrown by resip code.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
bool empty() const noexcept
Checks whether the Data is empty.
ClientPagerMessageHandle makePagerMessage(const NameAddr &target, const std::shared_ptr< UserProfile > &userProfile, AppDialogSet *=nullptr)
virtual Brief brief() const
return a facet for brief encoding of message
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
Represents a SIP message.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
Data getAorNoPort() const
Data getAOR(bool addPort) const
unsigned int ParticipantHandle
dcm! – add UnusedChecking(_enum) below;