added OnConnect Callback
[anytun.git] / src / syncOnConnect.hpp
blob35aa93a0a6466ea834f010a0336c9a8a5be275b7
2 void syncOnConnect(SyncTcpConnection * connptr)
4 ConnectionList & cl_(gConnectionList);
5 ConnectionMap::iterator cit = cl_.getBeginUnlocked();
6 for (;cit!=cl_.getEndUnlocked();++cit)
8 std::ostringstream sout;
9 boost::archive::text_oarchive oa(sout);
10 const SyncCommand scom(cl_,cit->first);
11 oa << scom;
12 std::stringstream lengthout;
13 lengthout << std::setw(5) << std::setfill('0') << sout.str().size()<< ' ';
14 connptr->Send(lengthout.str());
15 connptr->Send(sout.str());
17 //TODO Locking here
18 RoutingMap::iterator it = gRoutingTable.getBeginUnlocked();
19 for (;it!=gRoutingTable.getEndUnlocked();++it)
21 NetworkPrefix tmp(it->first);
22 std::ostringstream sout;
23 boost::archive::text_oarchive oa(sout);
24 const SyncCommand scom(tmp);
25 oa << scom;
26 std::stringstream lengthout;
27 lengthout << std::setw(5) << std::setfill('0') << sout.str().size()<< ' ';
28 connptr->Send(lengthout.str());
29 connptr->Send(sout.str());
31 //TODO Locking here
32 RtpSessionMap::iterator rit = gRtpSessionTable.getBeginUnlocked();
33 for (;rit!=gRtpSessionTable.getEndUnlocked();++rit)
35 std::ostringstream sout;
36 boost::archive::text_oarchive oa(sout);
37 const SyncCommand scom(rit->first);
38 oa << scom;
39 std::stringstream lengthout;
40 lengthout << std::setw(5) << std::setfill('0') << sout.str().size()<< ' ';
41 connptr->Send(lengthout.str());
42 connptr->Send(sout.str());