reSIProcate/DialogUsageManager  9694
test3pcc.cxx
Go to the documentation of this file.
00001 #include "resip/stack/SdpContents.hxx"
00002 #include "resip/stack/SipMessage.hxx"
00003 #include "resip/stack/ShutdownMessage.hxx"
00004 #include "resip/stack/SipStack.hxx"
00005 #include "resip/dum/ClientAuthManager.hxx"
00006 #include "resip/dum/ClientInviteSession.hxx"
00007 #include "resip/dum/ClientRegistration.hxx"
00008 #include "resip/dum/DialogUsageManager.hxx"
00009 #include "resip/dum/DumShutdownHandler.hxx"
00010 #include "resip/dum/InviteSessionHandler.hxx"
00011 #include "resip/dum/MasterProfile.hxx"
00012 #include "resip/dum/RegistrationHandler.hxx"
00013 #include "resip/dum/ServerInviteSession.hxx"
00014 #include "resip/dum/ServerOutOfDialogReq.hxx"
00015 #include "resip/dum/OutOfDialogHandler.hxx"
00016 #include "resip/dum/AppDialog.hxx"
00017 #include "resip/dum/AppDialogSet.hxx"
00018 #include "resip/dum/AppDialogSetFactory.hxx"
00019 #include "rutil/Log.hxx"
00020 #include "rutil/Logger.hxx"
00021 #include "rutil/Random.hxx"
00022 
00023 #include <sstream>
00024 #include <time.h>
00025 
00026 #define RESIPROCATE_SUBSYSTEM Subsystem::TEST
00027 
00028 using namespace resip;
00029 using namespace std;
00030 
00031 class Controller : public InviteSessionHandler
00032 {
00033    public:
00034       virtual void onNewSession(ClientInviteSessionHandle, InviteSession::OfferAnswerType oat, 
00035                                 const SipMessage& msg)
00036       {
00037       }
00038       
00039       virtual void onNewSession(ServerInviteSessionHandle, InviteSession::OfferAnswerType oat, 
00040                                 const SipMessage& msg)
00041       {
00042       }
00043 
00044       virtual void onFailure(ClientInviteSessionHandle, const SipMessage& msg)
00045       {
00046       }
00047       
00048       virtual void onProvisional(ClientInviteSessionHandle h, const SipMessage& msg)
00049       {
00050       }
00051 
00052       virtual void onConnected(ClientInviteSessionHandle, const SipMessage& msg)
00053       {
00054       }
00055 
00056       virtual void onStaleCallTimeout(ClientInviteSessionHandle)
00057       {
00058       }
00059 
00060       virtual void onConnected(InviteSessionHandle, const SipMessage& msg)
00061       {
00062       }
00063 
00064       virtual void onRedirected(ClientInviteSessionHandle, const SipMessage& msg)
00065       {
00066       }
00067 
00068       virtual void onTerminated(InviteSessionHandle, InviteSessionHandler::TerminatedReason reason, 
00069                                 const SipMessage* msg)
00070       {
00071       }
00072 
00073       virtual void onAnswer(InviteSessionHandle h, const SipMessage& msg, const SdpContents& sdp)
00074       {
00075          h->end();         
00076       }
00077 
00078       virtual void onOffer(InviteSessionHandle is, const SipMessage& msg, const SdpContents& sdp)      
00079       {
00080       }
00081 
00082       virtual void onEarlyMedia(ClientInviteSessionHandle, const SipMessage& msg, const SdpContents& sdp)
00083       {
00084       }
00085 
00086       virtual void onOfferRequired(InviteSessionHandle, const SipMessage& msg)
00087       {
00088       }
00089 
00090       virtual void onOfferRejected(InviteSessionHandle, const SipMessage& msg)
00091       {
00092       }
00093 
00094       virtual void onDialogModified(InviteSessionHandle, InviteSession::OfferAnswerType oat, 
00095                                     const SipMessage& msg)
00096       {
00097       }
00098 
00099       virtual void onInfo(InviteSessionHandle, const SipMessage& msg)
00100       {
00101       }
00102 
00103       virtual void onRefer(InviteSessionHandle, ServerSubscriptionHandle, const SipMessage& msg)
00104       {
00105       }
00106 
00107       virtual void onReferAccepted(InviteSessionHandle, ClientSubscriptionHandle, const SipMessage& msg)
00108       {
00109       }
00110 
00111       virtual void onReferRejected(InviteSessionHandle, const SipMessage& msg)
00112       {
00113       }
00114 
00115       virtual void onInfoSuccess(InviteSessionHandle, const SipMessage& msg)
00116       {
00117       }
00118 
00119       virtual void onInfoFailure(InviteSessionHandle, const SipMessage& msg)
00120       {
00121       }
00122 
00123       virtual void onForkDestroyed(ClientInviteSessionHandle)
00124           {
00125           }
00126 };
00127 
00128 
00129 int 
00130 main (int argc, char** argv)
00131 {
00132    Log::initialize(Log::Cout, resip::Log::Warning, argv[0]);
00133 
00134    DialogUsageManager controller;
00135    controller.addTransport(UDP, 12005);
00136 
00137    SharedPtr<MasterProfile> uacMasterProfile(new MasterProfile);      
00138    auto_ptr<ClientAuthManager> uacAuth(new ClientAuthManager);
00139    controller.setMasterProfile(uacMasterProfile);
00140    controller.setClientAuthManager(uacAuth);
00141 
00142    Controller invSessionHandler;
00143    controller.setInviteSessionHandler(&invSessionHandler);
00144 
00145    NameAddr controllerAor("sip:controller@internal.xten.net");
00146    controller.getMasterProfile()->setDefaultFrom(controllerAor);
00147    NameAddr target("sip:rohan@internal.xten.net");
00148 
00149    Data txt("v=0\r\n"
00150             "o=- 327064655 327074279 IN IP4 192.168.0.129\r\n"
00151             "s=3pcc test\r\n"
00152             "c=IN IP4 0.0.0.0\r\n"
00153             "t=0 0\r\n"
00154 //            "m=audio 7154 RTP/AVP 0\r\n"
00155 //            "a=sendrecv\r\n"
00156       );
00157             
00158    HeaderFieldValue hfv(txt.data(), txt.size());
00159    Mime type("application", "sdp");
00160    SdpContents sdp(&hfv, type);
00161    
00162    controller.send(controller.makeInviteSession(target, &sdp));
00163    
00164    
00165    int n = 0;
00166    while (true)
00167    {
00168      FdSet fdset;
00169      // Should these be buildFdSet on the DUM?
00170      controller.buildFdSet(fdset);
00171      int err = fdset.selectMilliSeconds(100);
00172      assert ( err != -1 );
00173      controller.process(fdset);
00174      if (!(n++ % 10)) cerr << "|/-\\"[(n/10)%4] << '\b';
00175    }   
00176    return 0;
00177 }
00178 
00179 /* ====================================================================
00180  * The Vovida Software License, Version 1.0 
00181  * 
00182  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00183  * 
00184  * Redistribution and use in source and binary forms, with or without
00185  * modification, are permitted provided that the following conditions
00186  * are met:
00187  * 
00188  * 1. Redistributions of source code must retain the above copyright
00189  *    notice, this list of conditions and the following disclaimer.
00190  * 
00191  * 2. Redistributions in binary form must reproduce the above copyright
00192  *    notice, this list of conditions and the following disclaimer in
00193  *    the documentation and/or other materials provided with the
00194  *    distribution.
00195  * 
00196  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00197  *    and "Vovida Open Communication Application Library (VOCAL)" must
00198  *    not be used to endorse or promote products derived from this
00199  *    software without prior written permission. For written
00200  *    permission, please contact vocal@vovida.org.
00201  *
00202  * 4. Products derived from this software may not be called "VOCAL", nor
00203  *    may "VOCAL" appear in their name, without prior written
00204  *    permission of Vovida Networks, Inc.
00205  * 
00206  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00207  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00208  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00209  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00210  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00211  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00212  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00213  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00214  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00215  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00216  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00217  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00218  * DAMAGE.
00219  * 
00220  * ====================================================================
00221  * 
00222  * This software consists of voluntary contributions made by Vovida
00223  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00224  * Inc.  For more information on Vovida Networks, Inc., please see
00225  * <http://www.vovida.org/>.
00226  *
00227  */