sipxtacklib  Version 3.3
SipClient.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 
12 #ifndef _SipClient_h_
13 #define _SipClient_h_
14 
15 // SYSTEM INCLUDES
16 //#include <...>
17 
18 // APPLICATION INCLUDES
19 #include <os/OsSocket.h>
20 #include <os/OsTask.h>
21 #include <os/OsServerTask.h>
22 #include <os/OsBSem.h>
23 #include <net/SipMessage.h>
24 
25 // DEFINES
26 // MACROS
27 // EXTERNAL FUNCTIONS
28 // EXTERNAL VARIABLES
29 // CONSTANTS
30 // STRUCTS
31 // TYPEDEFS
32 // FORWARD DECLARATIONS
33 class SipUserAgentBase;
34 class OsEvent;
35 
36 //:Class short description which may consist of multiple lines (note the ':')
37 // Class detailed description which may extend to multiple lines
38 class SipClient : public OsTask
39 {
40 /* //////////////////////////// PUBLIC //////////////////////////////////// */
41 public:
42 
43 /* ============================ CREATORS ================================== */
44 
45  SipClient(OsSocket* socket = NULL);
46  //:Default constructor
47 
48 
49  virtual
50  ~SipClient();
51  //:Destructor
52 
53 /* ============================ MANIPULATORS ============================== */
54  UtlBoolean send(SipMessage* message);
55 
56  UtlBoolean sendTo(const SipMessage& message,
57  const char* address,
58  int port);
59 
60  void setUserAgent(SipUserAgentBase* sipUA);
61  //void addEventConsumer(OsServerTask* messageEventListener);
62  //void removeEventConsumer(OsServerTask* messageEventListener);
63 
64 
65  virtual int run(void* pArg);
66 
67  UtlBoolean sendInvite(char* toAddress, char* callId, int rtpPort,
68  int numCodecs, int rtpCodecs[],
69  int sequenceNumber = 1);
70 
71  void touch();
72  //: Set the time when this client was last used
73  // This is potentially used for garbage collection
74 
75  void notifyWhenAvailableForWrite(OsEvent& availableEvent);
76  //: The given event is signaled when this SipClient is not busy
77 
79 
81 
82  void setSharedSocket(UtlBoolean bShared) ;
83 
84 /* ============================ ACCESSORS ================================= */
85 
86  //void getHostIp(UtlString* hostAddress) const;
87  void getClientNames(UtlString& clientNames) const;
88  long getLastTouchedTime() const;
89  //int getHostPort() const;
90  const UtlString& getLocalIp();
91 
92  void markInUseForWrite();
93  void markAvailbleForWrite();
94 
95 
96 /* ============================ INQUIRY =================================== */
97 
98  UtlBoolean isOk();
99 
100  UtlBoolean isConnectedTo(UtlString& hostName, int hostPort);
101 
102  int isInUseForWrite();
103 
104 /* //////////////////////////// PROTECTED ///////////////////////////////// */
105 protected:
106 
107 /* //////////////////////////// PRIVATE /////////////////////////////////// */
108 private:
109 
110  // Test whether the socket is ready to read. (Does not block.)
111  UtlBoolean isReadyToRead();
112  // Wait until the socket is ready to read (or has an error).
113  UtlBoolean waitForReadyToRead();
114 
115  OsSocket* clientSocket;
116  OsSocket::IpProtocolSocketType mSocketType;
117  SipUserAgentBase* sipUserAgent;
118  UtlString mRemoteHostName;
119  UtlString mRemoteViaAddress;
120  UtlString mRemoteSocketAddress;
121  UtlString mReceivedAddress;
122  int mRemoteViaPort;
123  int mRemoteHostPort;
124  int mRemoteReceivedPort;
125  long touchedTime;
126  OsBSem mSocketLock;
127  int mFirstResendTimeoutMs;
128  int mInUseForWrite;
129  UtlSList* mWaitingList; // Events waiting until this is available
130  UtlBoolean mbSharedSocket; // Shared socket-- do not delete or close (UDP / rport)
131 
132  SipClient(const SipClient& rSipClient);
133  //:disable Copy constructor
134 
135  SipClient& operator=(const SipClient& rhs);
136  //:disable Assignment operator
137 
138 };
139 
140 /* ============================ INLINE METHODS ============================ */
141 
142 #endif // _SipClient_h_
void markAvailbleForWrite()
Definition: SipClient.cpp:923
Definition: SipClient.h:38
UtlBoolean sendTo(const SipMessage &message, const char *address, int port)
Definition: SipClient.cpp:651
void signalNextAvailableForWrite()
Definition: SipClient.cpp:740
void getClientNames(UtlString &clientNames) const
Definition: SipClient.cpp:820
Specialization of HttpMessage to contain and manipulate SIP messages.
Definition: SipMessage.h:343
void markInUseForWrite()
Definition: SipClient.cpp:916
long getLastTouchedTime() const
Definition: SipClient.cpp:858
int isInUseForWrite()
Definition: SipClient.cpp:872
virtual ~SipClient()
Definition: SipClient.cpp:104
UtlBoolean sendInvite(char *toAddress, char *callId, int rtpPort, int numCodecs, int rtpCodecs[], int sequenceNumber=1)
void notifyWhenAvailableForWrite(OsEvent &availableEvent)
Definition: SipClient.cpp:727
const UtlString & getLocalIp()
Definition: SipClient.cpp:929
UtlBoolean isConnectedTo(UtlString &hostName, int hostPort)
Definition: SipClient.cpp:884
virtual int run(void *pArg)
Definition: SipClient.cpp:185
void signalAllAvailableForWrite()
Definition: SipClient.cpp:776
void setUserAgent(SipUserAgentBase *sipUA)
Definition: SipClient.cpp:852
void setSharedSocket(UtlBoolean bShared)
Definition: SipClient.cpp:814
Definition: SipUserAgentBase.h:44
UtlBoolean send(SipMessage *message)
Definition: SipClient.cpp:583
UtlBoolean isOk()
Definition: SipClient.cpp:879
SipClient(OsSocket *socket=NULL)
Definition: SipClient.cpp:65
void touch()
Definition: SipClient.cpp:863

sipXtackLib home page