Skip to content

Commit db8e5da

Browse files
committed
Cleanup TcpConnection class
1 parent 332cede commit db8e5da

2 files changed

Lines changed: 5 additions & 15 deletions

File tree

src/tcp.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,8 @@ TcpAddress::getPort() const {
6363
return mPort;
6464
}
6565

66-
TcpConnection::TcpConnection() : mLocal("192.168.1.1", 1234), mRemote("stringer.jibemobile.com", 8080) {
66+
TcpConnection::TcpConnection(const TcpAddress& first, const TcpAddress& second) : mFirst(first), mSecond(second) {
6767
}
6868

6969
TcpConnection::~TcpConnection() {
7070
}
71-
72-
TcpConnection*
73-
TcpConnection::newConnection() {
74-
return nullptr;
75-
}

src/tcp.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,20 @@ enum TcpConnectionState {
109109

110110
class TcpConnection {
111111
public:
112-
TcpConnection();
112+
TcpConnection(const TcpAddress& first, const TcpAddress& second);
113113
virtual ~TcpConnection();
114114

115115
virtual bool addPacket(const Buffer& data) = 0;
116116

117-
static TcpConnection* newConnection();
118-
119117
private:
120-
TcpAddress mLocal;
121-
TcpAddress mRemote;
118+
TcpAddress mFirst;
119+
TcpAddress mSecond;
122120
TcpConnectionState mState;
123121
};
124122

125123
class TcpConnectionManager {
126124
public:
127-
static TcpConnection* getConnection();
128-
129-
private:
130-
static list<pair<pair<TcpAddress, TcpAddress>, TcpConnection*>> sConnections;
125+
static TcpConnection* getConnection(const TcpAddress& first, const TcpAddress& second);
131126
};
132127

133128
#endif /* __TCP_H__ */

0 commit comments

Comments
 (0)