mirror of
https://github.com/edubart/otclient.git
synced 2025-10-16 04:24:54 +02:00
Some changes to server compatibility
This commit is contained in:
@@ -25,10 +25,11 @@
|
||||
|
||||
#include "declarations.h"
|
||||
#include <boost/asio.hpp>
|
||||
#include <framework/luaengine/luaobject.h>
|
||||
#include <framework/core/timer.h>
|
||||
#include <framework/core/declarations.h>
|
||||
|
||||
class Connection : public stdext::shared_object
|
||||
class Connection : public LuaObject
|
||||
{
|
||||
typedef std::function<void(const boost::system::error_code&)> ErrorCallback;
|
||||
typedef std::function<void(uint8*, uint16)> RecvCallback;
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "declarations.h"
|
||||
#include "inputmessage.h"
|
||||
#include "outputmessage.h"
|
||||
#include "connection.h"
|
||||
|
||||
#include <framework/luaengine/luaobject.h>
|
||||
|
||||
@@ -41,6 +42,8 @@ public:
|
||||
|
||||
bool isConnected();
|
||||
bool isConnecting();
|
||||
ConnectionPtr getConnection() { return m_connection; }
|
||||
void setConnection(const ConnectionPtr& connection) { m_connection = connection; }
|
||||
|
||||
void generateXteaKey();
|
||||
std::vector<int> getXteaKey();
|
||||
|
@@ -25,12 +25,17 @@
|
||||
|
||||
extern asio::io_service g_ioService;
|
||||
|
||||
Server::Server(uint16 port)
|
||||
Server::Server(int port)
|
||||
: m_acceptor(g_ioService, asio::ip::tcp::endpoint(asio::ip::tcp::v4(), port))
|
||||
{
|
||||
}
|
||||
|
||||
void Server::acceptNext(const AcceptCallback& acceptCallback)
|
||||
ServerPtr Server::create(int port)
|
||||
{
|
||||
return ServerPtr(new Server(port));
|
||||
}
|
||||
|
||||
void Server::acceptNext()
|
||||
{
|
||||
ConnectionPtr connection = ConnectionPtr(new Connection);
|
||||
connection->m_connecting = true;
|
||||
@@ -39,6 +44,6 @@ void Server::acceptNext(const AcceptCallback& acceptCallback)
|
||||
connection->m_connected = true;
|
||||
connection->m_connecting = false;
|
||||
}
|
||||
acceptCallback(connection, error);
|
||||
callLuaField("onAccept", connection, error.message(), error.value());
|
||||
});
|
||||
}
|
||||
|
@@ -24,15 +24,17 @@
|
||||
#define SERVER_H
|
||||
|
||||
#include "declarations.h"
|
||||
#include <framework/luaengine/luaobject.h>
|
||||
|
||||
class Server
|
||||
class Server : public LuaObject
|
||||
{
|
||||
typedef std::function<void(ConnectionPtr, const boost::system::error_code&)> AcceptCallback;
|
||||
|
||||
public:
|
||||
Server(uint16 port);
|
||||
Server(int port);
|
||||
static ServerPtr create(int port);
|
||||
|
||||
void acceptNext(const AcceptCallback& acceptCallback);
|
||||
void acceptNext();
|
||||
|
||||
private:
|
||||
asio::ip::tcp::acceptor m_acceptor;
|
||||
|
Reference in New Issue
Block a user