Skip to content
Snippets Groups Projects
Commit 6f71a96d authored by dg's avatar dg
Browse files

plop

git-svn-id: http://svn.net-core.org/repos/t-engine4@2890 51575b47-30f0-44d4-a5cc-537603b46e54
parent b1963222
No related branches found
No related tags found
No related merge requests found
...@@ -120,6 +120,7 @@ function _M:pread(ncode) ...@@ -120,6 +120,7 @@ function _M:pread(ncode)
end end
function _M:login() function _M:login()
print("profile login", self.sock , self.auth , self.user_login , self.user_pass)
if self.sock and not self.auth and self.user_login and self.user_pass then if self.sock and not self.auth and self.user_login and self.user_pass then
self:command("AUTH", self.user_login) self:command("AUTH", self.user_login)
self:read("200") self:read("200")
...@@ -193,6 +194,7 @@ function _M:run() ...@@ -193,6 +194,7 @@ function _M:run()
end end
function _M:handleOrder(o) function _M:handleOrder(o)
print("==== profile order ====", o)
o = o:unserialize() o = o:unserialize()
if not self.sock and o.o ~= "Login" and o.o ~= "CurrentCharacter" and o.o ~= "CheckModuleHash" then return end -- Dont do stuff without a connection, unless we try to auth if not self.sock and o.o ~= "Login" and o.o ~= "CurrentCharacter" and o.o ~= "CheckModuleHash" then return end -- Dont do stuff without a connection, unless we try to auth
if self["order"..o.o] then self["order"..o.o](self, o) end if self["order"..o.o] then self["order"..o.o](self, o) end
...@@ -212,13 +214,15 @@ function _M:orderNewProfile2(o) ...@@ -212,13 +214,15 @@ function _M:orderNewProfile2(o)
end end
function _M:orderLogin(o) function _M:orderLogin(o)
self.user_login = o.l
self.user_pass = o.p
print("profile strogin login info", o.l, o.p)
-- Already logged? -- Already logged?
if self.auth and self.auth.login == o.l then if self.auth and self.auth.login == o.l then
print("[PROFILE] reusing login", self.auth.name) print("[PROFILE] reusing login", self.auth.name)
cprofile.pushEvent(string.format("e='Auth' ok=%q", table.serialize(self.auth))) cprofile.pushEvent(string.format("e='Auth' ok=%q", table.serialize(self.auth)))
else else
self.user_login = o.l
self.user_pass = o.p
self:login() self:login()
end end
end end
...@@ -314,7 +318,9 @@ end ...@@ -314,7 +318,9 @@ end
function _M:orderChatJoin(o) function _M:orderChatJoin(o)
self:command("JOIN", o.channel) self:command("JOIN", o.channel)
self:read("200") if self:read("200") then
self.chat:joined(o.channel)
end
end end
function _M:orderChatUserInfo(o) function _M:orderChatUserInfo(o)
......
...@@ -25,6 +25,7 @@ local c = Client.new() ...@@ -25,6 +25,7 @@ local c = Client.new()
function step_profile() function step_profile()
local ok, res = xpcall(function() return c:run() end, function(...) server:logError("[profile-thread-error:stacktrace] %s", debug.traceback(...)) end) local ok, res = xpcall(function() return c:run() end, function(...) server:logError("[profile-thread-error:stacktrace] %s", debug.traceback(...)) end)
if not ok and res then if not ok and res then
print("[PROFILE THREAD] error", res)
return false return false
end end
return res return res
......
...@@ -67,6 +67,7 @@ int pop_order(lua_State *L) ...@@ -67,6 +67,7 @@ int pop_order(lua_State *L)
if (q) if (q)
{ {
// printf("[profile event] POP %s\n", q->payload);
lua_pushlstring(L, q->payload, q->payload_len); lua_pushlstring(L, q->payload, q->payload_len);
free(q->payload); free(q->payload);
free(q); free(q);
...@@ -141,11 +142,6 @@ int thread_profile(void *data) ...@@ -141,11 +142,6 @@ int thread_profile(void *data)
luaL_openlib(L, "cprofile", threadlib, 0); lua_pop(L, 1); luaL_openlib(L, "cprofile", threadlib, 0); lua_pop(L, 1);
profile->L = L; profile->L = L;
profile->iqueue_head = profile->iqueue_tail = profile->oqueue_head = profile->oqueue_tail = NULL;
profile->lock_iqueue = SDL_CreateMutex();
profile->wait_iqueue = SDL_CreateSemaphore(0);
profile->lock_oqueue = SDL_CreateMutex();
profile->wait_oqueue = SDL_CreateSemaphore(0);
// And run the lua engine pre init scripts // And run the lua engine pre init scripts
if (!luaL_loadfile(L, "/loader/pre-init.lua")) docall(L, 0, 0); if (!luaL_loadfile(L, "/loader/pre-init.lua")) docall(L, 0, 0);
...@@ -180,6 +176,11 @@ int create_profile_thread(lua_State *L) ...@@ -180,6 +176,11 @@ int create_profile_thread(lua_State *L)
main_profile = profile; main_profile = profile;
profile->running = TRUE; profile->running = TRUE;
profile->iqueue_head = profile->iqueue_tail = profile->oqueue_head = profile->oqueue_tail = NULL;
profile->lock_iqueue = SDL_CreateMutex();
profile->wait_iqueue = SDL_CreateSemaphore(0);
profile->lock_oqueue = SDL_CreateMutex();
profile->wait_oqueue = SDL_CreateSemaphore(0);
thread = SDL_CreateThread(thread_profile, profile); thread = SDL_CreateThread(thread_profile, profile);
if (thread == NULL) { if (thread == NULL) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment