-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclientsocket.h
More file actions
48 lines (40 loc) · 1.11 KB
/
clientsocket.h
File metadata and controls
48 lines (40 loc) · 1.11 KB
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
42
43
44
45
46
47
48
#ifndef CLIENTSOCKET_H
#define CLIENTSOCKET_H
#include <dirent.h>
#include "abstractsocket.h"
#include "supertcpmanager.h"
#include "serversocket.h"
class ServerSocket;
class ClientSocket : public AbstractSocket
{
public:
ClientSocket(int sockfd, SuperTcpManager &tcpManager, ServerSocket* server);
ClientSocket(int sockfd, SuperTcpManager &tcpManager, std::function<void(int)> dataReceived, char *buffer, size_t bufferSize, ServerSocket *server = nullptr);
void send(const std::string& message);
void setFunction(std::function<void(int)> callback);
void setBuffer(char *buffer);
void setBufferSize(size_t bufferSize);
void close();
~ClientSocket();
private:
void receiveData();
ServerSocket* server;
std::function<void(int)> userFunc;
char* buffer;
size_t bufferSize;
public:
bool isEnableRead() const
{
return enableRead;
}
void setEnableRead(bool enableRead)
{
ClientSocket::enableRead = enableRead;
}
private:
bool enableRead;
std::string message;
ssize_t countSended;
void sendData();
};
#endif // CLIENTSOCKET_H