Files
NP_Midterm/impl/Session/Session.cpp

60 lines
1.3 KiB
C++

//#include "Session/Session.hpp"
//#include "Socket/Log.hpp"
//#include "precomp.hpp"
//#include <thread>
//
//namespace Chattr {
//
//Session::Session(Chattr::TCPSocket __sock) {
// init(std::move(__sock));
//}
//
//Session::~Session() {
// destruct();
//}
//
//void Session::init(Chattr::TCPSocket __sock) {
// sock_ = std::move(__sock);
//}
//
//void Session::destruct() {
//}
//
//TCPSocket Session::reconnect(Chattr::TCPSocket __sock, int maxTry) {
// int retVal = 0;
// int backoffTime = 2;
//
// __sock.destruct();
//
// spdlog::info("Lost connection.");
// while (maxTry--) {
// backoffTime *= backoffTime;
// spdlog::info("Attempt to reconnect in {}s...", backoffTime);
// std::this_thread::sleep_for(std::chrono::seconds(backoffTime));
// TCPSocket sock;
//
// retVal = sock.init(__sock.domain);
// if (retVal == INVALID_SOCKET || retVal == SOCKET_ERROR) {
// log::error("init()");
// continue;
// }
// retVal = sock.connect(__sock.remoteAddr);
// if (retVal == INVALID_SOCKET || retVal == SOCKET_ERROR) {
// log::error("connect()");
// continue;
// }
//
// return sock;
// }
// return TCPSocket();
//}
//
//int Session::recv(void* __restrict __buf, size_t __n, int __flags) {
// return -1;
//}
//
//int Session::send(const void* __buf, size_t __n, int __flags) {
// return -1;
//}
//
//}