コード例 #1
0
void TCPConnectionPair::setClientSocket(const net::TCPSocket::Ptr& socket)
{
	TraceLS(this) << "Set client socket: "
		<< connectionID << ": " << socket->peerAddress()  << endl;	
		//<< ": " << socket./*base().*/refCount()
	assert(client == nullptr);
	//assert(socket./*base().*/refCount() == 2);
	client = socket;
	client->Close += sdelegate(this, &TCPConnectionPair::onConnectionClosed);
	net::setServerSocketBufSize<uv_tcp_t>(*socket.get(), SERVER_SOCK_BUF_SIZE); // TODO: make option
}
コード例 #2
0
void Server::onTCPAcceptConnection(void*, const net::TCPSocket::Ptr& sock)
{
    TraceL << "TCP connection accepted: " << sock->peerAddress() << endl;    
    
    //assert(sock./*base().*/refCount() == 1);
    _tcpSockets.push_back(sock);
    net::TCPSocket::Ptr& socket = _tcpSockets.back();
    //assert(socket./*base().*/refCount() == 2);
    socket->Recv += sdelegate(this, &Server::onSocketRecv);
    socket->Close += sdelegate(this, &Server::onTCPSocketClosed);

    // No need to increase control socket buffer size
    // setServerSocketBufSize<net::TCPSocket>(socket, SERVER_SOCK_BUF_SIZE); // TODO: make option
}
コード例 #3
0
void TCPConnectionPair::setPeerSocket(const net::TCPSocket::Ptr& socket)
{	
	TraceLS(this) << "Set peer socket: " 
		<< connectionID << ": " << socket->peerAddress() << endl;	
		//<< ": " << socket./*base().*/refCount() 

	assert(peer == nullptr);
	//assert(socket./*base().*/refCount() == 1);
	peer = socket;
	peer->Close += sdelegate(this, &TCPConnectionPair::onConnectionClosed);
	
	// Receive and buffer early media from peer
	peer->Recv += sdelegate(this, &TCPConnectionPair::onPeerDataReceived);	
	net::setServerSocketBufSize<uv_tcp_t>(*socket.get(), SERVER_SOCK_BUF_SIZE); // TODO: make option
}