sipXcallLib home page


TaoClientTask.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 _TaoClient_h_
13 #define _TaoClient_h_
14 
15 #if _MSC_VER >= 1000
16 #pragma once
17 #endif // _MSC_VER >= 1000
18 
19 // SYSTEM INCLUDES
20 
21 // APPLICATION INCLUDES
22 #include "os/OsServerTask.h"
23 #include "os/OsBSem.h"
24 #include "os/OsLock.h"
25 #include "tao/TaoMessage.h"
26 #include "tao/TaoServerTask.h"
27 #include "tao/TaoTransportAgent.h"
28 #include "TaoDefs.h" // Added by ClassView
29 
30 // DEFINES
31 // MACROS
32 // EXTERNAL FUNCTIONS
33 // EXTERNAL VARIABLES
34 // CONSTANTS
35 // STRUCTS
36 // TYPEDEFS
37 // FORWARD DECLARATIONS
39 class TaoTransportTask;
40 class OsConnectionSocket;
41 class PtEventListener;
45 class PtCallListener;
46 class PtTerminalListener;
47 
48 //:Used to build the call originating part, establishes connection with the server
49 // through the TaoTransport. Maintains a db of listeners the client has registered.
50 class TaoClientTask : public OsServerTask
51 {
52 /* //////////////////////////// PUBLIC //////////////////////////////////// */
53 public:
54 /* ============================ CREATORS ================================== */
55  TaoClientTask(int remotePort,
56  UtlString remoteHost,
57  TaoServerTask *pTaoServerTask = NULL,
58  const UtlString& name="TaoClientTask-%d",
59  const int maxRequestQMsgs=DEF_MAX_MSGS);
60  //:Constructor
61 
62  TaoClientTask(TaoServerTask *pTaoServerTask = NULL,
63  const UtlString& name="TaoClientTask-%d",
64  void* pArg=NULL,
65  const int maxRequestQMsgs=DEF_MAX_MSGS,
66  const int priority=DEF_PRIO,
67  const int options=DEF_OPTIONS,
68  const int stackSize=DEF_STACKSIZE);
69  //:Constructor
70 
71  TaoClientTask(const int maxIncomingQMsgs, TaoServerTask *pTaoServerTask = NULL);
72  //:Constructor
73 
74  TaoClientTask(const TaoClientTask& rTaoClientTask);
75  //:Copy constructor (not implemented for this class)
76 
77  virtual ~TaoClientTask();
78 /* ============================ MANIPULATORS ============================== */
79 
80  virtual void requestShutdown(void);
81 
82  int sendRequest(TaoMessage& rMsg, OsMutex* pMutex = 0, const OsTime& rTimeout=OsTime::OS_INFINITY);
83 
84  virtual UtlBoolean handleMessage(OsMsg& rMsg);
85  //:Handle an incoming message.
86  // If the message is not one that the object is prepared to process,
87  // the handleMessage() method in the derived class should return FALSE
88  // which will cause the OsServerTask::handleMessage() method to be
89  // invoked on the message.
90 
91  void addEventListener(PtEventListener* pListener, const char* callId = NULL);
92 
93  void removeEventListener(PtEventListener& rListener);
94 
95  int resetConnectionSocket(int transactionId);
96 
97 /* ============================ ACCESSORS ================================ */
98 
100 
101 /* //////////////////////////// PRIVATE ////////////////////////////////// */
102 private:
103 friend class PtTerminal;
104 
105 /* ============================ FUNCTIONS ================================ */
107 
108  UtlBoolean receiveMsg(TaoMessage& rMsg);
109 
110  int readUntilDone(OsConnectionSocket* pSocket, char *pBuf, int iLength) ;
111  //: read iLength bytes from passed socket (waiting until completion)
112 
113 /* ============================ VARIABLES ================================ */
115 
117  OsConnectionSocket* mpConnectionSocket;
118 
119  int mRemotePort; // TaoServer's listener port
120  UtlString mRemoteHost; // remote TaoServer
121  OsRWMutex mMutex; // mutex for synchonizing access to data
122 
124 
126 
127 private:
128 
129 
130 };
131 
132 #endif // _TaoClient_h_
int mRemotePort
Definition: TaoClientTask.h:119
UtlString mRemoteHost
Definition: TaoClientTask.h:120
Definition: TaoMessage.h:51
Definition: PtTerminalConnectionListener.h:33
OsConnectionSocket * mpConnectionSocket
Definition: TaoClientTask.h:117
OsRWMutex mMutex
Definition: TaoClientTask.h:121
TaoStatus initInstance()
Definition: TaoClientTask.cpp:154
Definition: PtTerminalComponentListener.h:34
void addEventListener(PtEventListener *pListener, const char *callId=NULL)
Definition: TaoClientTask.cpp:338
virtual UtlBoolean handleMessage(OsMsg &rMsg)
Definition: TaoClientTask.cpp:175
Definition: PtCallListener.h:33
UtlBoolean receiveMsg(TaoMessage &rMsg)
Definition: TaoClientTask.cpp:239
Definition: TaoTransportTask.h:45
TaoListenerClientTask * mpListenerTask
Definition: TaoClientTask.h:114
Definition: PtEventListener.h:55
virtual void requestShutdown(void)
Definition: TaoClientTask.cpp:119
virtual ~TaoClientTask()
Definition: TaoClientTask.cpp:91
TaoObjHandle getEventServer()
Definition: TaoClientTask.h:99
TaoTransportTask * mpTransport
Definition: TaoClientTask.h:116
Definition: TaoListenerClient.h:58
TaoStatus
Definition: TaoDefs.h:41
Definition: PtTerminal.h:178
Definition: TaoServerTask.h:49
Definition: TaoTransportAgent.h:37
TaoClientTask(int remotePort, UtlString remoteHost, TaoServerTask *pTaoServerTask=NULL, const UtlString &name="TaoClientTask-%d", const int maxRequestQMsgs=DEF_MAX_MSGS)
Definition: TaoClientTask.cpp:34
TaoServerTask * mpTaoServerTask
Definition: TaoClientTask.h:123
int resetConnectionSocket(int transactionId)
Definition: TaoClientTask.cpp:372
int readUntilDone(OsConnectionSocket *pSocket, char *pBuf, int iLength)
Definition: TaoClientTask.cpp:354
uintptr_t TaoObjHandle
Definition: TaoDefs.h:32
Definition: PtConnectionListener.h:33
int sendRequest(TaoMessage &rMsg, OsMutex *pMutex=0, const OsTime &rTimeout=OsTime::OS_INFINITY)
Definition: TaoClientTask.cpp:278
Definition: TaoClientTask.h:50
Definition: PtTerminalListener.h:31
void removeEventListener(PtEventListener &rListener)
Definition: TaoClientTask.cpp:346
TaoTransportAgent * mpAgent
Definition: TaoClientTask.h:125