diff options
-rw-r--r-- | syncSocket.cpp | 31 | ||||
-rw-r--r-- | syncSocket.h | 3 |
2 files changed, 25 insertions, 9 deletions
diff --git a/syncSocket.cpp b/syncSocket.cpp index f22ad21..5db5fbd 100644 --- a/syncSocket.cpp +++ b/syncSocket.cpp @@ -9,6 +9,8 @@ //#include "connectionParam.h" #include "Sockets/Utility.h" #include "syncSocket.h" +#include "buffer.h" +//#include "log.h" SyncSocket::SyncSocket(ISocketHandler& h,ConnectionList & cl) :TcpSocket(h),cl_(cl) @@ -47,18 +49,31 @@ void SyncSocket::OnAccept() boost::archive::text_oarchive oa(sout); const ConnectionParam conn = cl_.getConnection(); oa << conn; - Send(sout.str()); + Send(sout.str()+"\n"); } } -void SyncSocket::OnRawData(const char *buf,size_t len) +//void SyncSocket::OnRawData(const char *buf,size_t len) +void SyncSocket::OnLine(const std::string& line) { - std::cout << "recieved sync inforamtaion:"<< std::endl; - for(size_t index=0;index<len;index++) - { - std::cout << buf[index]; - } - std::cout << std::endl; +// std::cout << "recieved sync inforamtaion:"<< std::endl; +// for(size_t index=0;index<len;index++) +// { +// std::cout << buf[index]; +// } + std::cout << line << std::endl; + std::istringstream iss; + iss.str(line); + boost::archive::text_iarchive ia(iss); + SeqWindow * seq= new SeqWindow(0); + seq_nr_t seq_nr_=0; + KeyDerivation * kd = new KeyDerivation; + kd->init(::Buffer(), ::Buffer()); + ConnectionParam conn ( (*kd), (*seq), seq_nr_, "", 0); + ia >> conn; + std::cout << "sync connection remote host " << conn.remote_host_ << ":" << conn.remote_port_ << std::endl; + cl_.clear(); + cl_.addConnection(conn,std::string("default")); } //void StatusSocket::InitSSLServer() //{ diff --git a/syncSocket.h b/syncSocket.h index 31169c1..66fa842 100644 --- a/syncSocket.h +++ b/syncSocket.h @@ -18,7 +18,8 @@ public: bool OnConnectRetry(); void OnReconnect(); - void OnRawData(const char *buf,size_t len); + void OnLine(const std::string& line); +// void OnRawData(const char *buf,size_t len); // void Init(); // void InitSSLServer(); |