5 #include <boost/archive/text_oarchive.hpp>
6 #include <boost/archive/text_iarchive.hpp>
10 //#include "connectionParam.h"
11 #include "Sockets/Utility.h"
12 #include "syncClientSocket.h"
16 SyncClientSocket::SyncClientSocket(ISocketHandler
& h
,ConnectionList
& cl
)
17 :TcpSocket(h
),cl_(cl
),missing_chars(-1),buffer_size_(0)
19 // initial connection timeout setting and number of retries
20 SetConnectTimeout(12);
21 SetConnectionRetry(-1); //infinite reties
23 // Also reconnect broken link
28 bool SyncClientSocket::OnConnectRetry()
34 void SyncClientSocket::OnReconnect()
36 cLog
.msg(Log::PRIO_NOTICE
) << "reconnected with " << GetRemoteHostname() << std::endl
;
38 //Send("Welcome back\r\n");
42 void SyncClientSocket::OnRawData(const char *buf
,size_t len
)
43 //void SyncClientSocket::OnLine(const std::string& line)
45 for(size_t index
=0;index
<len
;index
++)
47 // std::cout << buf[index];
53 // cLog.msg(Log::PRIO_NOTICE) << "buffer size "<< buffer_size_ << " missing_chars " << missing_chars;
54 if(missing_chars
==-1 && buffer_size_
>5)
56 char * buffer
= new char [6+1];
58 std::stringstream tmp
;
61 // cLog.msg(Log::PRIO_NOTICE) << "recieved sync inforamtaion length from " << GetRemoteHostname() <<" "<<tmp.str()<<"bytes of data"<< std::endl;
65 if(missing_chars
>0 && missing_chars
<=buffer_size_
)
67 char * buffer
= new char [missing_chars
+1];
68 iss_
.read(buffer
,missing_chars
);
69 std::stringstream tmp
;
70 tmp
.write(buffer
,missing_chars
);
71 // cLog.msg(Log::PRIO_NOTICE) << "recieved sync inforamtaion from " << GetRemoteHostname() <<" \""<<tmp.str()<<'"'<< std::endl;
72 boost::archive::text_iarchive
ia(tmp
);
73 SyncCommand
scom(cl_
);
75 buffer_size_
-=missing_chars
;
82 //u_int16_t mux = scom.getMux();
83 //const ConnectionParam & conn = cl_.getConnection(mux)->second;
84 //cLog.msg(Log::PRIO_NOTICE) << "sync connection #"<<mux<<" remote host " << conn.remote_host_ << ":" << conn.remote_port_ << std::endl;
87 //void StatusClientSocket::InitSSLServer()
89 // InitializeContext("server.pem", "keypwd", SSLv23_method());
93 //void StatusClientSocket::Init()