Add getIp function, remove unused sql function
This commit is contained in:
parent
8753f82fd0
commit
7fb2f6deb5
|
@ -660,6 +660,7 @@ void Application::registerLuaFunctions()
|
||||||
|
|
||||||
// Connection
|
// Connection
|
||||||
g_lua.registerClass<Connection>();
|
g_lua.registerClass<Connection>();
|
||||||
|
g_lua.bindClassMemberFunction<Connection>("getIp", &Connection::getIp);
|
||||||
|
|
||||||
// Protocol
|
// Protocol
|
||||||
g_lua.registerClass<Protocol>();
|
g_lua.registerClass<Protocol>();
|
||||||
|
@ -737,7 +738,6 @@ void Application::registerLuaFunctions()
|
||||||
g_lua.bindClassMemberFunction<DBResult>("getDataInt", &DBResult::getDataInt);
|
g_lua.bindClassMemberFunction<DBResult>("getDataInt", &DBResult::getDataInt);
|
||||||
g_lua.bindClassMemberFunction<DBResult>("getDataLong", &DBResult::getDataLong);
|
g_lua.bindClassMemberFunction<DBResult>("getDataLong", &DBResult::getDataLong);
|
||||||
g_lua.bindClassMemberFunction<DBResult>("getDataString", &DBResult::getDataString);
|
g_lua.bindClassMemberFunction<DBResult>("getDataString", &DBResult::getDataString);
|
||||||
//g_lua.bindClassMemberFunction<DBResult>("getDataStream", &DBResult::getDataStream);
|
|
||||||
g_lua.bindClassMemberFunction<DBResult>("next", &DBResult::next);
|
g_lua.bindClassMemberFunction<DBResult>("next", &DBResult::next);
|
||||||
|
|
||||||
// Mysql
|
// Mysql
|
||||||
|
|
|
@ -240,3 +240,13 @@ void Connection::handleError(const boost::system::error_code& error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Connection::getIp()
|
||||||
|
{
|
||||||
|
boost::system::error_code error;
|
||||||
|
const boost::asio::ip::tcp::endpoint ip = m_socket.remote_endpoint(error);
|
||||||
|
if(!error)
|
||||||
|
return boost::asio::detail::socket_ops::host_to_network_long(ip.address().to_v4().to_ulong());
|
||||||
|
|
||||||
|
g_logger.error("Getting remote ip");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ public:
|
||||||
|
|
||||||
void setErrorCallback(const ErrorCallback& errorCallback) { m_errorCallback = errorCallback; }
|
void setErrorCallback(const ErrorCallback& errorCallback) { m_errorCallback = errorCallback; }
|
||||||
|
|
||||||
|
int getIp();
|
||||||
boost::system::error_code getError() { return m_error; }
|
boost::system::error_code getError() { return m_error; }
|
||||||
bool isConnecting() { return m_connecting; }
|
bool isConnecting() { return m_connecting; }
|
||||||
bool isConnected() { return m_connected; }
|
bool isConnected() { return m_connected; }
|
||||||
|
|
|
@ -263,25 +263,6 @@ std::string DBResult::getDataString(const std::string &s)
|
||||||
return std::string("");
|
return std::string("");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* DBResult::getDataStream(const std::string &s, unsigned long &size)
|
|
||||||
{
|
|
||||||
ListNames::iterator it = m_listNames.find(s);
|
|
||||||
if(it != m_listNames.end() ) {
|
|
||||||
if(m_row[it->second] == NULL) {
|
|
||||||
size = 0;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
size = mysql_fetch_lengths(m_res)[it->second];
|
|
||||||
return m_row[it->second];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_logger.error(stdext::format("error during getDataStream(%s).", s));
|
|
||||||
size = 0;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DBResult::next()
|
bool DBResult::next()
|
||||||
{
|
{
|
||||||
m_row = mysql_fetch_row(m_res);
|
m_row = mysql_fetch_row(m_res);
|
||||||
|
|
|
@ -71,7 +71,6 @@ public:
|
||||||
int32_t getDataInt(const std::string &s);
|
int32_t getDataInt(const std::string &s);
|
||||||
int64_t getDataLong(const std::string &s);
|
int64_t getDataLong(const std::string &s);
|
||||||
std::string getDataString(const std::string &s);
|
std::string getDataString(const std::string &s);
|
||||||
const char* getDataStream(const std::string &s, unsigned long &size);
|
|
||||||
|
|
||||||
bool next();
|
bool next();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue