Public Member Functions
TimeRequest Class Reference

Brief description of class still missing. More...

#include <TimeRequest.h>

Inheritance diagram for TimeRequest:
GpCoreTools::Timer

List of all members.

Public Member Functions

virtual bool exec ()
 TimeRequest (uint16_t port, int delay=2000)

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

TimeRequest::TimeRequest ( uint16_t  port,
int  delay = 2000 
)

Description of constructor still missing

References GpCoreTools::Timer::setInterval().

    : Timer()
{
  setInterval(delay);
  _port=port;
  loadHostNames();
}

Member Function Documentation

bool TimeRequest::exec ( ) [virtual]

Sent data are packed in a MessageRaw structure (tag code, byte length and checksum). Payload contains a TimeData object

Implements GpCoreTools::Timer.

References GpCoreTools::MessageRaw< Payload >::buffer(), GpCoreTools::TcpClientStream::connect(), TimeData::currentTime(), GpCoreTools::Address::fromString(), GpCoreTools::MessageRaw< Payload >::littleEndianValues(), GpCoreTools::MessageRaw< Payload >::payload(), and GpCoreTools::TcpClientStream::write().

{
#pragma pack(1)
  MessageRaw<TimeData> msg;
  msg.payload().currentTime();
  msg.littleEndianValues();
#pragma pack()
  updateHostList();
  Log::write(0, "send time requests...\n");
  Address peer;
  for(std::list<std::string>::iterator it=_activeHosts.begin(); it!=_activeHosts.end(); it++) {
    peer.fromString(it->data());
    if(peer!=Address::me()) {
      TimeSlaveStream * l=new TimeSlaveStream(peer);
      if(l->connect(_port)) {
        l->write(msg.buffer(), sizeof(msg));
        EventLoop::instance()->addStream(l); // Automatically deleted after hungup
      } else {
        delete l;
      }
    }
  }
  return true; // Repeat this request
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines