From 17498a97a289119debdb651ab898ddea99e86ff9 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 29 Jan 2015 11:09:56 +0100 Subject: cNetwork: Exported lookup functions to Lua API. Also added an example in the NetworkTest plugin. --- src/Bindings/LuaNameLookup.h | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/Bindings/LuaNameLookup.h (limited to 'src/Bindings/LuaNameLookup.h') diff --git a/src/Bindings/LuaNameLookup.h b/src/Bindings/LuaNameLookup.h new file mode 100644 index 000000000..8b456ad90 --- /dev/null +++ b/src/Bindings/LuaNameLookup.h @@ -0,0 +1,46 @@ + +// LuaNameLookup.h + +// Declares the cLuaNameLookup class used as the cNetwork API callbacks for name and IP lookups from Lua + + + + + +#pragma once + +#include "../OSSupport/Network.h" +#include "PluginLua.h" + + + + + +class cLuaNameLookup: + public cNetwork::cResolveNameCallbacks +{ +public: + /** Creates a new instance of the lookup callbacks for the specified query, + attached to the specified lua plugin and wrapping the callbacks that are in a table at the specified stack pos. */ + cLuaNameLookup(const AString & a_Query, cPluginLua & a_Plugin, int a_CallbacksTableStackPos); + +protected: + /** The plugin for which the link is created. */ + cPluginLua & m_Plugin; + + /** The Lua table that holds the callbacks to be invoked. */ + cLuaState::cRef m_Callbacks; + + /** The query used to start the lookup (either hostname or IP). */ + AString m_Query; + + + // cNetwork::cResolveNameCallbacks overrides: + virtual void OnNameResolved(const AString & a_Name, const AString & a_IP) override; + virtual void OnError(int a_ErrorCode, const AString & a_ErrorMsg) override; + virtual void OnFinished(void) override; +}; + + + + -- cgit v1.2.3 From 014b96adb33fa902072d9f35661bc4f5e7c323e8 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 30 Jan 2015 21:24:02 +0100 Subject: Exported cServerHandle and cNetwork:Listen to Lua. Also added an example to the NetworkTest plugin. --- src/Bindings/LuaNameLookup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Bindings/LuaNameLookup.h') diff --git a/src/Bindings/LuaNameLookup.h b/src/Bindings/LuaNameLookup.h index 8b456ad90..e4cdb9f53 100644 --- a/src/Bindings/LuaNameLookup.h +++ b/src/Bindings/LuaNameLookup.h @@ -25,7 +25,7 @@ public: cLuaNameLookup(const AString & a_Query, cPluginLua & a_Plugin, int a_CallbacksTableStackPos); protected: - /** The plugin for which the link is created. */ + /** The plugin for which the query is created. */ cPluginLua & m_Plugin; /** The Lua table that holds the callbacks to be invoked. */ -- cgit v1.2.3