⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 presencedialinserver.cpp

📁 基于sipfoundy 公司开发的sipx协议API
💻 CPP
📖 第 1 页 / 共 2 页
字号:
                                callId.data(), address.data());               }               else               {                  // Create a CallContainer object and insert it into the call list                  CallContainer* thisCall = new CallContainer(callId, address, mpIncomingQ);                  mCalls.insertKeyAndValue(new UtlString(callId), thisCall);                                    // Get the feature code from the request url                  requestUrl = Url(entity);                  requestUrl.getUserId(featureCode);                  contactUrl = Url(address);                  contactUrl.getIdentity(contact);                  OsSysLog::add(FAC_SIP, PRI_DEBUG, "PresenceDialInServer:: contact %s request for %s",                                contact.data(), featureCode.data());                                    if (featureCode.compareTo(mSignInFC) == 0)                  {                     if (notifyStateChange(contact, true))                     {                        if (mSignInConfirmationAudio == NULL)                        {                           // Play built-in default sign-in confirmation audio tone                           mpCallManager->bufferPlay(callId,                                                     (int)confirmationTone,                                                     confirmationToneLength,                                                     RAW_PCM_16,                                                     FALSE, FALSE, TRUE);                        }                        else                        {                           // Play user specified sign-in confirmation audio                           mpCallManager->audioPlay(callId,                                                    mSignInConfirmationAudio,                                                    FALSE, FALSE, TRUE);                        }                     }                     else                     {                        if (mErrorAudio == NULL)                        {                           // Play built-in default error audio tone                           mpCallManager->bufferPlay(callId,                                                     (int)busyTone,                                                     busyToneLength,                                                     RAW_PCM_16,                                                     FALSE, FALSE, TRUE);                        }                        else                        {                           // Play user specified error audio                           mpCallManager->audioPlay(callId,                                                    mErrorAudio,                                                    FALSE, FALSE, TRUE);                        }                        OsSysLog::add(FAC_SIP, PRI_DEBUG, "PresenceDialInServer:: contact %s has already signed in",                                      contact.data());                     }                                          }                                    if (featureCode.compareTo(mSignOutFC) == 0)                  {                     if (notifyStateChange(contact, false))                     {                        if (mSignOutConfirmationAudio == NULL)                        {                           // Play built-in default sign-out confirmation audio tone                           mpCallManager->bufferPlay(callId,                                                     (int)dialTone,                                                     dialToneLength,                                                     RAW_PCM_16,                                                     FALSE, FALSE, TRUE);                        }                        else                        {                           // Play user specified sign-out confirmation audio                           mpCallManager->audioPlay(callId, mSignOutConfirmationAudio, FALSE, FALSE, TRUE);                        }                     }                     else                     {                        if (mErrorAudio == NULL)                        {                           // Play built-in default error audio tone                           mpCallManager->bufferPlay(callId,                                                     (int)busyTone,                                                     busyToneLength,                                                     RAW_PCM_16,                                                     FALSE, FALSE, TRUE);                        }                        else                        {                           // Play user specified error audio                           mpCallManager->audioPlay(callId,                                                    mErrorAudio,                                                    FALSE, FALSE, TRUE);                        }                        OsSysLog::add(FAC_SIP, PRI_DEBUG, "PresenceDialInServer:: contact %s has already signed out",                                      contact.data());                     }                  }                                    OsTime timerTime(SECONDS_DELAY, 0);                  thisCall->mTimer->oneshotAfter(timerTime);                                                                           }            }            break;         case PtEvent::CONNECTION_DISCONNECTED:            if (!localConnection)             {               mpCallManager->getSipDialog(callId, address, sipDialog);#ifdef DEBUGGING                           sipDialog.toString(sipDialogContent);               OsSysLog::add(FAC_SIP, PRI_DEBUG, "PresenceDialInServer:: sipDialog = %s",                              sipDialogContent.data());#endif                           sipDialog.getLocalContact(requestUrl);               requestUrl.getIdentity(entity);               OsSysLog::add(FAC_SIP, PRI_DEBUG, "Call dropped: %s address %s with entity %s",                             callId.data(), address.data(), entity.data());               if (entity.isNull())               {                  OsSysLog::add(FAC_SIP, PRI_WARNING, "PresenceDialInServer:: Call dropped: callId %s address %s without requestUrl",                                 callId.data(), address.data());               }                              // Remove the CallContainer object from the call list               mCalls.destroy(&callId);            }            break;                     case PtEvent::CONNECTION_FAILED:            OsSysLog::add(FAC_SIP, PRI_WARNING, "Connection failed on call: %s", callId.data());            break;      }   }   else   {       if(msgType == OsMsg::OS_EVENT && msgSubType == OsEventMsg::NOTIFY)       {         CallContainer* thisCall = NULL;         ((OsEventMsg&)rMsg).getUserData((int&)thisCall);         mpCallManager->dropConnection(thisCall->mCallId, thisCall->mAddress);       }   }         return(TRUE);}/* ============================ ACCESSORS ================================= */void PresenceDialInServer::addStateChangeNotifier(const char* fileUrl, StateChangeNotifier* notifier){   mLock.acquire();   UtlString* name = new UtlString(fileUrl);   UtlVoidPtr* value = new UtlVoidPtr(notifier);   mStateChangeNotifiers.insertKeyAndValue(name, value);   mLock.release();}void PresenceDialInServer::removeStateChangeNotifier(const char* fileUrl){   mLock.acquire();   UtlString name(fileUrl);   mStateChangeNotifiers.destroy(&name);   mLock.release();} /* ============================ INQUIRY =================================== *//* //////////////////////////// PROTECTED ///////////////////////////////// */void PresenceDialInServer::dumpTaoMessageArgs(unsigned char eventId, TaoString& args) {   OsSysLog::add(FAC_SIP, PRI_DEBUG, "===>Message type: %d args:\n", eventId) ;           int argc = args.getCnt();   for(int argIndex = 0; argIndex < argc; argIndex++)   {      OsSysLog::add(FAC_SIP, PRI_DEBUG, "\targ[%d]=\"%s\"", argIndex, args[argIndex]);   }}/* //////////////////////////// PRIVATE /////////////////////////////////// */bool PresenceDialInServer::notifyStateChange(UtlString& contact, bool signIn){   bool result = false;      // Loop through the notifier list   UtlHashMapIterator iterator(mStateChangeNotifiers);   UtlString* listUri;   StateChangeNotifier* notifier;   UtlVoidPtr* container;   Url contactUrl(contact);   mLock.acquire();   while ((listUri = dynamic_cast <UtlString *> (iterator())) != NULL)   {      container = dynamic_cast <UtlVoidPtr *> (mStateChangeNotifiers.findValue(listUri));      notifier = (StateChangeNotifier *) container->getValue();      if (signIn)      {         result = notifier->setStatus(contactUrl, StateChangeNotifier::PRESENT);      }      else      {         result = notifier->setStatus(contactUrl, StateChangeNotifier::AWAY);      }   }   mLock.release();      return result;}/* ============================ TESTING =================================== *//* ============================ FUNCTIONS ================================= */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -