Changeset 5531 for source/ariba/utility
- Timestamp:
- Jul 31, 2009, 1:29:21 PM (15 years ago)
- Location:
- source/ariba/utility/bootstrap/modules/periodicbroadcast
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/utility/bootstrap/modules/periodicbroadcast/PeriodicBroadcast.cpp
r5529 r5531 58 58 59 59 use_logging_cpp(PeriodicBroadcast); 60 const long PeriodicBroadcast::timerinterval = 2 000;61 const long PeriodicBroadcast::servicetimeout = 5 000;60 const long PeriodicBroadcast::timerinterval = 2; 61 const long PeriodicBroadcast::servicetimeout = 5; 62 62 const unsigned int PeriodicBroadcast::serverport_v4 = 5634; 63 63 const unsigned int PeriodicBroadcast::serverport_v6 = 5636; … … 91 91 boost::bind(&PeriodicBroadcast::threadFunc, this) ); 92 92 93 Timer::setInterval( timerinterval );93 Timer::setInterval( timerinterval*1000 ); 94 94 Timer::start(); 95 95 } … … 149 149 for( ; i != iend; i++ ){ 150 150 151 if( time(NULL) > (i->second.lastseen + (servicetimeout/1000)) ){151 if( time(NULL) > (i->second.lastseen + 1000) ){ 152 152 remoteServices.erase( i ); 153 153 deleted = true; … … 173 173 if( i != remoteServices.end() ) { 174 174 // update the item lastseen time 175 i->second. lastseen = service.lastseen;175 i->second.setLastseen( service.getLastseen() ); 176 176 continue; 177 177 } … … 184 184 } 185 185 186 callback->onBootstrapServiceFound(name, service.info1, service.info2, service.info3); 186 callback->onBootstrapServiceFound(name, 187 service.getInfo1(), service.getInfo2(), service.getInfo3()); 187 188 } 188 189 -
source/ariba/utility/bootstrap/modules/periodicbroadcast/PeriodicBroadcast.h
r5516 r5531 90 90 static const unsigned int serverport_v6; 91 91 92 typedef struct _Service { 92 class Service { 93 private: 93 94 string name; 94 95 string info1; … … 97 98 time_t lastseen; 98 99 99 _Service() 100 public: 101 Service() 100 102 : name(""), info1(""), info2(""), info3(""), lastseen(0){ 101 103 } 102 104 103 _Service(const string& _name, const string& _info1,105 Service(const string& _name, const string& _info1, 104 106 const string& _info2, const string& _info3, const time_t& _lastseen = 0){ 105 107 name.assign (_name); … … 110 112 } 111 113 112 _Service(const _Service& rh){114 Service(const Service& rh){ 113 115 name.assign (rh.name); 114 116 info1.assign(rh.info1); … … 117 119 lastseen = rh.lastseen; 118 120 } 119 } Service; 121 122 string getName() const { 123 return name; 124 } 125 126 string getInfo1() const { 127 return info1; 128 } 129 130 string getInfo2() const { 131 return info2; 132 } 133 134 string getInfo3() const { 135 return info3; 136 } 137 138 time_t getLastseen() const { 139 return lastseen; 140 } 141 142 void setName(string _name){ 143 name.assign(_name); 144 } 145 146 void setInfo1(string _info1){ 147 info1.assign(_info1); 148 } 149 150 void setInfo2(string _info2){ 151 info2.assign(_info2); 152 } 153 154 void setInfo3(string _info3){ 155 info3.assign(_info3); 156 } 157 158 void setLastseen(time_t _lastseen){ 159 lastseen = _lastseen; 160 } 161 162 Service& operator=(const Service& rh){ 163 this->name.assign( rh.getName() ); 164 this->info1.assign( rh.getInfo1() ); 165 this->info2.assign( rh.getInfo2() ); 166 this->info3.assign( rh.getInfo3() ); 167 this->lastseen = rh.lastseen; 168 return *this; 169 } 170 }; 120 171 121 172 typedef map<string,Service> ServiceList; … … 225 276 PeriodicBroadcastMessage msg; 226 277 227 msg.setName( service. name);228 msg.setInfo1( service. info1);229 msg.setInfo2( service. info2);230 msg.setInfo3( service. info3);278 msg.setName( service.getName() ); 279 msg.setInfo1( service.getInfo1() ); 280 msg.setInfo2( service.getInfo2() ); 281 msg.setInfo3( service.getInfo3() ); 231 282 232 283 Data data = data_serialize( msg, DEFAULT_V ); … … 301 352 if( it != services->end() ){ 302 353 303 it->second. info1.assign( msg.getInfo1() );304 it->second. info2.assign( msg.getInfo2() );305 it->second. info3.assign( msg.getInfo3() );306 it->second. lastseen = time(NULL);354 it->second.setInfo1( msg.getInfo1() ); 355 it->second.setInfo2( msg.getInfo2() ); 356 it->second.setInfo3( msg.getInfo3() ); 357 it->second.setLastseen( time(NULL) ); 307 358 308 359 } else {
Note:
See TracChangeset
for help on using the changeset viewer.