Cuberite
A lightweight, fast and extensible game server for Minecraft
LuaNameLookup.cpp
Go to the documentation of this file.
1 
2 // LuaNameLookup.cpp
3 
4 // Implements the cLuaNameLookup class used as the cNetwork API callbacks for name and IP lookups from Lua
5 
6 #include "Globals.h"
7 #include "LuaNameLookup.h"
8 
9 
10 
11 
12 
14  m_Callbacks(std::move(a_Callbacks)),
15  m_Query(a_Query)
16 {
17 }
18 
19 
20 
21 
22 
23 void cLuaNameLookup::OnNameResolved(const AString & a_Name, const AString & a_IP)
24 {
25  m_Callbacks->CallTableFn("OnNameResolved", a_Name, a_IP);
26 }
27 
28 
29 
30 
31 
32 void cLuaNameLookup::OnError(int a_ErrorCode, const AString & a_ErrorMsg)
33 {
34  m_Callbacks->CallTableFn("OnError", m_Query, a_ErrorCode, a_ErrorMsg);
35 }
36 
37 
38 
39 
40 
42 {
43  m_Callbacks->CallTableFn("OnFinished", m_Query);
44 }
45 
46 
47 
48 
std::string AString
Definition: StringUtils.h:11
Definition: FastNBT.h:132
virtual void OnError(int a_ErrorCode, const AString &a_ErrorMsg) override
Called when an error is encountered while resolving.
AString m_Query
The query used to start the lookup (either hostname or IP).
Definition: LuaNameLookup.h:32
cLuaState::cTableRefPtr m_Callbacks
The Lua table that holds the callbacks to be invoked.
Definition: LuaNameLookup.h:29
virtual void OnNameResolved(const AString &a_Name, const AString &a_IP) override
Called when the hostname is successfully resolved into an IP address.
cLuaNameLookup(const AString &a_Query, cLuaState::cTableRefPtr &&a_Callbacks)
Creates a new instance of the lookup callbacks for the specified query, using the callbacks that are ...
virtual void OnFinished(void) override
Called when all the addresses resolved have been reported via the OnNameResolved() callback.
std::unique_ptr< cTableRef > cTableRefPtr
Definition: LuaState.h:419