FACT++  1.0
template<class T>
int StateMachineFAD< T >::Transition ( const Event evt)
inline

Definition at line 367 of file dclient5.cc.

References EventImp::GetText(), Connection::PostClose(), Connection::PostMessage(), and Connection::SetEndpoint().

368  {
369  ConnectionFAD *con1 = &c1;
370  ConnectionFAD *con2 = &c2;
371 
372  switch (evt.GetTargetState())
373  {
374  case kSM_SetUrl:
375  T::Out() << evt.GetText() << endl;
376  c1.SetEndpoint(evt.GetText());
377  return T::GetCurrentState();
378  case kSM_Reconnect:
379  // Close all connections
380  c1.PostClose(false);
381  c2.PostClose(false);
382  c3.PostClose(false);
383 
384  // Now wait until all connection have been closed and
385  // all pending handlers have been processed
386  poll();
387 
388  // Now we can reopen the connection
389  c1.PostClose(true);
390  c2.PostClose(true);
391  c3.PostClose(true);
392 
393 
394  //c4.PostClose(true);
395  //c5.PostClose(true);
396  //c6.PostClose(true);
397  //c7.PostClose(true);
398  //c8.PostClose(true);
399  //c9.PostClose(true);
400  return T::GetCurrentState();
401  case kSM_Running: // We are coming from kRunning
402  case kSM_Starting: // We are coming from kConnected
403  T::Out() << "Received START" << endl;
404  con1->PostMessage("START", 10);
405  con2->PostMessage("START", 10);
406  // We could introduce a "waiting for execution" state
407  return T::GetCurrentState();
408  return kSM_Starting; //GetCurrentState();
409 
410  case kSM_Connected: // We are coming from kConnected
411  case kSM_Stopping: // We are coming from kRunning
412  T::Out() << "Received STOP" << endl;
413  con1->PostMessage("STOP", 10);
414  con2->PostMessage("STOP", 10);
415  // We could introduce a "waiting for execution" state
416  return T::GetCurrentState();
417  return kSM_Stopping;//GetCurrentState();
418  }
419 
420  return T::kSM_FatalError; //evt.GetTargetState();
421  }
void PostMessage(const void *msg, size_t s=0)
void PostClose(bool restart=true)
Definition: Connection.cc:125
const char * GetText() const
Definition: EventImp.h:88
void SetEndpoint(const std::string &addr, int port)
ConnectionFAD c1
Definition: dclient5.cc:195
ConnectionFAD c3
Definition: dclient5.cc:197
ConnectionFAD c2
Definition: dclient5.cc:196

+ Here is the call graph for this function: