master
Eduardo Bart 13 years ago
parent 70f0b0dace
commit 81ff15fe6b

@ -1,9 +1,6 @@
function EnterGame_connectToLoginServer() function EnterGame_connectToLoginServer()
-- create login protocol -- create login protocol
local protocolLogin = ProtocolLogin.create() local protocolLogin = ProtocolLogin.create()
print(ProtocolLogin_mt)
print(Protocol_mt)
print(getmetatable(protocolLogin))
-- used to recreate enter game window -- used to recreate enter game window
local recreateEnterGame = function() local recreateEnterGame = function()
@ -14,9 +11,9 @@ function EnterGame_connectToLoginServer()
local loadBox = displayCancelBox("Please wait", "Connecting..") local loadBox = displayCancelBox("Please wait", "Connecting..")
-- cancel loading callback -- cancel loading callback
loadBox.onCancel = function(protocol) loadBox.onCancel = function(msgbox)
-- cancel protocol and reacreate enter game window -- cancel protocol and reacreate enter game window
protocol:cancel() protocolLogin:cancel()
recreateEnterGame() recreateEnterGame()
end end
@ -29,7 +26,7 @@ function EnterGame_connectToLoginServer()
local errorBox = displayErrorBox("Login Error", error) local errorBox = displayErrorBox("Login Error", error)
-- cancel protocol and reacreate enter game window -- cancel protocol and reacreate enter game window
protocol.cancel() protocol:cancel()
errorBox.onOk = recreateEnterGame errorBox.onOk = recreateEnterGame
end end

@ -41,7 +41,7 @@ void ProtocolLogin::login(const std::string& accountName, const std::string& acc
//std::string host = "tecserver.zapto.org"; //std::string host = "tecserver.zapto.org";
uint16 port = 7171; uint16 port = 7171;
connect(host, port, std::bind(&ProtocolLogin::onConnect, this)); connect(host, port, std::bind(&ProtocolLogin::onConnect, asProtocolLogin()));
} }
void ProtocolLogin::onConnect() void ProtocolLogin::onConnect()

@ -22,6 +22,9 @@ public:
void onRecv(InputMessage *inputMessage); void onRecv(InputMessage *inputMessage);
void cancel() { /* TODO: this func */ } void cancel() { /* TODO: this func */ }
ProtocolLoginPtr asProtocolLogin() { return std::static_pointer_cast<ProtocolLogin>(shared_from_this()); }
virtual const char* getLuaTypeName() const { return "ProtocolLogin"; } virtual const char* getLuaTypeName() const { return "ProtocolLogin"; }
private: private:

Loading…
Cancel
Save