58 {
60
62 char buf[64] = {};
65 std::string connName = buf;
66
67 sockaddr_in local = {};
68 socklen_t addrLen = sizeof(local);
69 if (::getsockname(socketFd, (sockaddr*)&local, &addrLen) < 0)
70 {
71 std::stringstream ss;
72 ss << "TcpServer::NewConnection::getsockname error, fd: " << socketFd << ", Error: " << WSAGetLastError();
73
74 SPICES_CORE_ERROR(ss.str())
75 }
76 InetAddress localAddress(local);
77
78 const TcpConnectionPtr connectionPtr = std::make_shared<TcpConnection>(ioLoop, connName, socketFd, localAddress, peerAddress);
80
84
85 DelegateCloseCallback closeCallback;
87 connectionPtr->SetCloseCallback(closeCallback);
88
89 ioLoop->RunInLoop([=]() { connectionPtr->ConnectEstablished(); });
90 }
#define SPICES_PROFILE_ZONE
std::shared_ptr< EventLoopThreadPool > m_ThreadPool
ThreadPool.
ConnectionMap m_Connections
All TcpConnections.
DelegateWriteCompleteCallback m_WriteCompleteCallback
WriteCompleteCallback.
void RemoveConnection(const TcpConnectionPtr &connection)
Remove a TcpConnection.
std::string m_IpPort
TcpServer Ip and Port.
DelegateConnectionCallback m_ConnectionCallback
ConnectionCallback.
int m_NextConnectedId
Next Connection id.
DelegateMessageCallback m_MessageCallback
MessageCallback.
std::shared_ptr< TcpConnection > TcpConnectionPtr