mirror of
https://github.com/edubart/otclient.git
synced 2025-12-29 02:47:12 +01:00
add server class to framework
This commit is contained in:
@@ -32,8 +32,9 @@ class Connection : public std::enable_shared_from_this<Connection>, boost::nonco
|
||||
typedef std::function<void(uint8*, uint16)> RecvCallback;
|
||||
|
||||
enum {
|
||||
READ_TIMEOUT = 10,
|
||||
WRITE_TIMEOUT = 10
|
||||
READ_TIMEOUT = 30,
|
||||
WRITE_TIMEOUT = 30,
|
||||
RECV_BUFFER_SIZE = 65536
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -48,17 +49,18 @@ public:
|
||||
|
||||
void write(uint8* buffer, uint16 size);
|
||||
void read(uint16 bytes, const RecvCallback& callback);
|
||||
void read_some(const RecvCallback& callback);
|
||||
|
||||
void setErrorCallback(const ErrorCallback& errorCallback) { m_errorCallback = errorCallback; }
|
||||
|
||||
bool isConnecting() const { return m_connecting; }
|
||||
bool isConnected() const { return m_connected; }
|
||||
|
||||
private:
|
||||
protected:
|
||||
void onResolve(const boost::system::error_code& error, asio::ip::tcp::resolver::iterator endpointIterator);
|
||||
void onConnect(const boost::system::error_code& error);
|
||||
void onWrite(const boost::system::error_code& error, size_t);
|
||||
void onRecv(const boost::system::error_code& error);
|
||||
void onRecv(const boost::system::error_code& error, size_t recvSize);
|
||||
void onTimeout(const boost::system::error_code& error);
|
||||
void handleError(const boost::system::error_code& error);
|
||||
|
||||
@@ -71,10 +73,11 @@ private:
|
||||
asio::ip::tcp::resolver m_resolver;
|
||||
asio::ip::tcp::socket m_socket;
|
||||
|
||||
uint8 m_recvBuffer[65538];
|
||||
uint16 m_recvSize;
|
||||
uint8 m_recvBuffer[RECV_BUFFER_SIZE];
|
||||
bool m_connected;
|
||||
bool m_connecting;
|
||||
|
||||
friend class Server;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user