-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathTcpServer.cc
More file actions
41 lines (33 loc) · 714 Bytes
/
TcpServer.cc
File metadata and controls
41 lines (33 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//author voidccc
#include <errno.h>
#include "TcpServer.h"
#include "Channel.h"
#include "Acceptor.h"
#include "TcpConnection.h"
#include <vector>
TcpServer::TcpServer(EventLoop* pLoop)
:_pAcceptor(NULL)
,_pLoop(pLoop)
,_pUser(NULL)
{
}
TcpServer::~TcpServer()
{
}
void TcpServer::start()
{
_pAcceptor = new Acceptor(_pLoop); // Memory Leak !!!
_pAcceptor->setCallback(this);
_pAcceptor->start();
}
void TcpServer::newConnection(int sockfd)
{
TcpConnection* tcp = new TcpConnection(sockfd, _pLoop); // Memory Leak !!!
_connections[sockfd] = tcp;
tcp->setUser(_pUser);
tcp->connectEstablished();
}
void TcpServer::setCallback(IMuduoUser* user)
{
_pUser = user;
}