17 #include "TApplication.h"
19 #include "TObjArray.h"
22 #include "TGo4LockGuard.h"
50 UInt_t negotiationport,
56 :
TGo4Task(name,blockingmode, autostart,autocreate,ismaster),
57 fxTaskManager(0),fxCurrentTaskHandler(0),
58 fxConnectTransport(0), fxDisConnectTransport(0),
59 fuConnectPort(0), fbKeepServerSocket(kFALSE),
60 fbConnectRequest(kFALSE), fbDisConnectRequest(kFALSE),
61 fbConnectIsOpen(kFALSE),fbConnectIsDone(kFALSE), fbConnectIsClose(kFALSE),
64 TString nomen(
"TaskManager of "); nomen += name;
67 if(negotiationport!=42)
70 nomen.Form(
"ConnectorRunnable of %s", name);
72 nomen.Form(
"CONNECTOR-%s", name);
105 if(name && strstr(name,
"current"))
112 TGo4Log::Debug(
" ServerTask -- RemoveClient FAILED, no client %s !!! ",
133 TGo4Log::Debug(
" Server Task -- Waiting for client %s disconnection...",taskhandler->GetName());
141 TGo4Log::Debug(
" !!! Server Task -- client remove wait TIMEOUT !!! ");
147 TGo4Log::Debug(
" !!! Server Task -- client remove aborted for TERMINATION MODE !!! ");
153 TGo4Log::Debug(
" Server Task -- waited %d cycles until client was removed. ",removeresult);
162 TGo4Log::Debug(
" !!! Server Task -- removing client %s without waiting... ",
163 taskhandler->GetName());
184 names.AddLast(
new TNamed(taskhandler->GetName(),
"title"));
188 while((nomen =niter.Next()) !=0)
207 TGo4Log::Debug(
" Server task -- removing current client %s ",taskhandler->GetName());
223 TGo4Log::Debug(
" TGo4ServerTask ''%s'' ERROR- task manager not existing!!! ");
259 TGo4Log::Debug(
" ServerTask: FAILED setting current task to %s-- no such client! ",name);
467 if(name==0 || strstr(name,
"current"))
494 if(name==0 || strstr(name,
"current"))
515 if(comq==0)
continue;
541 Bool_t reset = kTRUE;
545 if(statq==0)
continue;
546 TGo4Log::Debug(
" Task - sending status %s to task %s", stat->ClassName(), han->GetName());
562 if(statq==0)
continue;
563 TGo4Log::Debug(
" Task - sending status buffer to task %s", han->GetName());
579 const char* host = gSystem->HostName();
583 connector->
Open(host,negotiationport);
599 TGo4Log::Debug(
" ServerTask Quit -- removing all connected clients ");
600 SendStatusMessage(2,kTRUE,
"ServerTask %s is shutting down now! All clients are removed...",GetName());
623 TGo4Log::Debug(
" ServerTask Shutdown without disconnect waiting");
624 SendStatusMessage(2,kTRUE,
"ServerTask %s is shutting down now! All clients are removed...",GetName());
643 gApplication->Terminate();
virtual Bool_t RemoveClient(const char *name, Bool_t clientwait=kTRUE, Bool_t isterminating=kFALSE)
virtual void SendStatus(TGo4Status *stat, const char *receiver=0)
TGo4Thread * GetThread(const char *name)
Bool_t fbDisConnectRequest
virtual Int_t StartWorkThreads()
virtual Int_t Close(Option_t *opt="")
TObject * WaitObjectFromBuffer()
TGo4TaskHandler * NextTaskHandler(Bool_t reset=kFALSE)
void WakeCommandQueue(Int_t id=0)
virtual void SendStatusBuffer()
static const UInt_t fguCONNECTWAITCYCLETIME
virtual Int_t Send(TObject *obj)
Int_t WaitForConnection()
static void UnRegister(TGo4CommandReceiver *p)
UInt_t GetNegotiationPort()
TGo4ThreadHandler * fxWorkHandler
void SetTaskName(const char *)
Bool_t RemoveCurrentClient()
TGo4Queue * GetStatusQueue() const
void SetDisConnect(TGo4Socket *trans)
static const char * Get_fgcERROR()
TGo4TaskConnectorTimer * fxConnectorTimer
static void Sleep(UInt_t millisecs)
static void Register(const char *name, TGo4CommandReceiver *p)
void SendStopBuffers(const char *taskname=0)
virtual Int_t Open(const char *host, Int_t port, Bool_t keepservsock=kFALSE)
Bool_t NewThread(const char *name, TGo4Runnable *runnable)
TGo4Queue * GetCommandQueue() const
virtual Int_t StopWorkThreads()
void SetConnect(TGo4Socket *trans, const char *host, UInt_t port, Bool_t keepserv=kFALSE)
TGo4TaskHandler * fxCurrentTaskHandler
virtual Bool_t StopConnectorThread()
static const UInt_t fguCONNECTTIMERPERIOD
virtual TGo4Command * NextCommand()
TGo4Socket * fxDisConnectTransport
static const UInt_t fguCLOSEWAITCYCLETIME
virtual Int_t TimerConnect()
static const char * Get_fgcLAUNCHPREFSFILE()
const char * GetConnectHost() const
Int_t DisConnectClient(const char *name, Bool_t clientwait=kTRUE)
TGo4Queue * GetDataQueue() const
virtual void SendStatus(TGo4Status *stat, const char *receiver=0)
static TGo4CommandInvoker * Instance()
TGo4BufferQueue * GetStatusQueue(const char *task=0)
static const Int_t fgiCONNECTWAITCYCLES
TGo4TaskHandler * GetTaskHandler(const char *name)
static const UInt_t fguOPENWAITCYCLETIME
TGo4ThreadHandler * GetWorkHandler() const
Bool_t SubmitEmergencyCommand(Go4EmergencyCommand_t val)
static const Int_t fgiOPENWAITCYCLES
void AddBuffer(TBuffer *buffer, Bool_t clone=kFALSE)
Bool_t Stop(const char *thname)
Bool_t ConnectorThreadIsStopped()
Bool_t Start(const char *thname)
void SendStatusMessage(Int_t level, Bool_t printout, const char *text,...)
Bool_t fbKeepServerSocket
TGo4ServerTask(const char *name, UInt_t negotiationport=0, Bool_t blockingmode=kFALSE, Bool_t standalone=kFALSE, Bool_t autostart=kTRUE, Bool_t autocreate=kTRUE, Bool_t ismaster=kTRUE)
TGo4Socket * GetConnectTransport()
TGo4BufferQueue * GetCommandQueue(const char *task=0)
virtual void Terminate(Bool_t termapp=kTRUE)
TGo4TaskManager * fxTaskManager
Go4CommandMode_t GetRole()
virtual Int_t RemoveAllClients(Bool_t force=false)
void SetTask(TGo4Task *task, Bool_t delold=kTRUE)
static const Int_t fgiCLOSEWAITCYCLES
TGo4BufferQueue * GetDataQueue(const char *task=0)
TGo4TaskHandler * GetLastTaskHandler()
virtual ~TGo4ServerTask()
Bool_t IsTerminating() const
static Int_t Get_fgiTERMID()
void SetMode(Go4CommandMode_t m)
TGo4TaskHandler * GetCurrentTaskHandler()
Int_t WaitForClientRemoved()
void SetCurrentTask(const char *name)
static const char * fgcLAUNCHPREFSFILE
Bool_t SubmitEmergencyData(Go4EmergencyCommand_t val, const char *receiver=0)
void AddBufferFromObject(TObject *object)
TGo4TaskHandler * GetTaskHandler()
TGo4TaskManager * GetTaskManager()
TGo4Socket * fxConnectTransport
static void Debug(const char *text,...)
const char * GetConnectorName() const
virtual Bool_t StartConnectorThread()