~ubuntu-branches/ubuntu/saucy/resiprocate/saucy-proposed

« back to all changes in this revision

Viewing changes to apps/clicktocall/clicktocall.cxx

  • Committer: Package Import Robot
  • Author(s): Daniel Pocock
  • Date: 2012-05-17 19:29:59 UTC
  • Revision ID: package-import@ubuntu.com-20120517192959-vv00m77isztdy64q
Tags: upstream-1.8.2
ImportĀ upstreamĀ versionĀ 1.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <signal.h>
 
2
 
 
3
#include "AppSubsystem.hxx"
 
4
#include "Server.hxx"
 
5
 
 
6
#include <rutil/Log.hxx>
 
7
#include <rutil/Logger.hxx>
 
8
#include <rutil/DnsUtil.hxx>
 
9
#include <rutil/BaseException.hxx>
 
10
#include <resip/stack/NameAddr.hxx>
 
11
#include <rutil/WinLeakCheck.hxx>
 
12
 
 
13
using namespace clicktocall;
 
14
using namespace resip;
 
15
using namespace std;
 
16
 
 
17
#define RESIPROCATE_SUBSYSTEM AppSubsystem::CLICKTOCALL
 
18
 
 
19
void sleepSeconds(unsigned int seconds)
 
20
{
 
21
#ifdef WIN32
 
22
   Sleep(seconds*1000);
 
23
#else
 
24
   sleep(seconds);
 
25
#endif
 
26
}
 
27
 
 
28
static bool finished = false;
 
29
 
 
30
static void
 
31
signalHandler(int signo)
 
32
{
 
33
   std::cerr << "Shutting down..." << endl;
 
34
   finished = true;
 
35
}
 
36
 
 
37
int 
 
38
main (int argc, char** argv)
 
39
{
 
40
#ifndef _WIN32
 
41
   if ( signal( SIGPIPE, SIG_IGN) == SIG_ERR)
 
42
   {
 
43
      cerr << "Couldn't install signal handler for SIGPIPE" << endl;
 
44
      exit(-1);
 
45
   }
 
46
#else
 
47
#if defined(_DEBUG) && defined(LEAK_CHECK)
 
48
   resip::FindMemoryLeaks fml;
 
49
#endif
 
50
#endif
 
51
 
 
52
   if ( signal( SIGINT, signalHandler ) == SIG_ERR )
 
53
   {
 
54
      cerr << "Couldn't install signal handler for SIGINT" << endl;
 
55
      exit( -1 );
 
56
   }
 
57
 
 
58
   if ( signal( SIGTERM, signalHandler ) == SIG_ERR )
 
59
   {
 
60
      cerr << "Couldn't install signal handler for SIGTERM" << endl;
 
61
      exit( -1 );
 
62
   }
 
63
 
 
64
   initNetwork();
 
65
 
 
66
   //////////////////////////////////////////////////////////////////////////////
 
67
   // Create Server
 
68
   //////////////////////////////////////////////////////////////////////////////
 
69
   {
 
70
      Server server(argc, argv);
 
71
 
 
72
      //////////////////////////////////////////////////////////////////////////////
 
73
      // Startup and run...
 
74
      //////////////////////////////////////////////////////////////////////////////
 
75
 
 
76
      server.startup();
 
77
 
 
78
      while(true)
 
79
      {
 
80
         server.process(50);
 
81
         if(finished) break;
 
82
      }
 
83
 
 
84
      server.shutdown();
 
85
   }
 
86
 
 
87
   InfoLog(<< "ClickToCall server is shutdown.");
 
88
   sleepSeconds(2);
 
89
}
 
90
 
 
91
/* ====================================================================
 
92
 
 
93
 Copyright (c) 2009, SIP Spectrum, Inc.
 
94
 All rights reserved.
 
95
 
 
96
 Redistribution and use in source and binary forms, with or without
 
97
 modification, are permitted provided that the following conditions are 
 
98
 met:
 
99
 
 
100
 1. Redistributions of source code must retain the above copyright 
 
101
    notice, this list of conditions and the following disclaimer. 
 
102
 
 
103
 2. Redistributions in binary form must reproduce the above copyright
 
104
    notice, this list of conditions and the following disclaimer in the
 
105
    documentation and/or other materials provided with the distribution. 
 
106
 
 
107
 3. Neither the name of SIP Spectrum nor the names of its contributors 
 
108
    may be used to endorse or promote products derived from this 
 
109
    software without specific prior written permission. 
 
110
 
 
111
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 
112
 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 
113
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
 
114
 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
 
115
 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 
116
 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
 
117
 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 
118
 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
 
119
 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 
120
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 
121
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
122
 
 
123
 ==================================================================== */
 
124