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

fix

git-svn-id: http://svn.net-core.org/repos/t-engine4@2893 51575b47-30f0-44d4-a5cc-537603b46e54
parent a7ed90d5
No related branches found
No related tags found
No related merge requests found
......@@ -73,14 +73,14 @@ function _M:event(e)
self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
self.channels[e.channel].users[e.login] = {name=e.name, login=e.login}
self.channels_changed = true
self:addMessage(e.channel, e.user, "#{italic}##FIREBRICK#has joined the channel#{normal}#")
if type(game) == "table" and game.log and e.channel == self.cur_channel then game.log("#{italic}##FIREBRICK#%s has joined channel %s (press space to talk).#{normal}#", e.user, e.channel) end
self:addMessage(e.channel, e.login, e.name, "#{italic}##FIREBRICK#has joined the channel#{normal}#")
if type(game) == "table" and game.log and e.channel == self.cur_channel then game.log("#{italic}##FIREBRICK#%s has joined channel %s (press space to talk).#{normal}#", e.login, e.channel) end
elseif e.se == "Part" then
self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
self.channels[e.channel].users[e.login] = nil
self.channels_changed = true
self:addMessage(e.channel, e.user, "#{italic}##FIREBRICK#has left the channel#{normal}#")
if type(game) == "table" and game.log and e.channel == self.cur_channel then game.log("#{italic}##FIREBRICK#%s has left channel %s.#{normal}#", e.user, e.channel) end
self:addMessage(e.channel, e.login, e.name, "#{italic}##FIREBRICK#has left the channel#{normal}#")
if type(game) == "table" and game.log and e.channel == self.cur_channel then game.log("#{italic}##FIREBRICK#%s has left channel %s.#{normal}#", e.login, e.channel) end
elseif e.se == "UserInfo" then
local info = e.data:unserialize()
if not info then return end
......
......@@ -328,6 +328,13 @@ function _M:orderChatJoin(o)
end
end
function _M:orderChatPart(o)
self:command("Part", o.channel)
if self:read("200") then
self.chat:parted(o.channel)
end
end
function _M:orderChatUserInfo(o)
self:command("UINF", o.user)
if self:read("200") then
......
......@@ -25,33 +25,41 @@ module(..., package.seeall, class.make)
function _M:init(client)
self.client = client
self.channels = {}
self.joined = {}
self.cjoined = {}
end
function _M:event(e)
if e.e == "ChatTalk" then
cprofile.pushEvent(string.format("e='Chat' se='Talk' channel=%q login=%q name=%q msg=%q", e.channel, e.login, e.name, e.msg))
print("[USERCHAT] channel talk", e.user, e.channel, e.msg)
print("[USERCHAT] channel talk", e.login, e.channel, e.msg)
elseif e.e == "ChatJoin" then
self.channels[e.channel] = self.channels[e.channel] or {}
self.channels[e.channel][e.user] = true
self.channels[e.channel][e.login] = true
cprofile.pushEvent(string.format("e='Chat' se='Join' channel=%q login=%q name=%q ", e.channel, e.login, e.name))
print("[USERCHAT] channel join", e.user, e.channel)
print("[USERCHAT] channel join", e.login, e.channel)
elseif e.e == "ChatPart" then
self.channels[e.channel] = self.channels[e.channel] or {}
self.channels[e.channel][e.user] = nil
self.channels[e.channel][e.login] = nil
cprofile.pushEvent(string.format("e='Chat' se='Part' channel=%q login=%q name=%q ", e.channel, e.login, e.name))
print("[USERCHAT] channel part", e.user, e.channel)
print("[USERCHAT] channel part", e.login, e.channel)
end
end
function _M:joined(channel)
self.joined[channel] = true
self.cjoined[channel] = true
print("[ONLINE PROFILE] connected to channel", channel)
end
function _M:parted(channel)
self.cjoined[channel] = nil
print("[ONLINE PROFILE] parted from channel", channel)
end
function _M:reconnect()
-- Rejoin every channels
for chan, _ in pairs(self.joined) do
client:orderChatJoin{channel=chan}
print("[ONLINE PROFILE] reconnecting to channels")
for chan, _ in pairs(self.cjoined) do
print("[ONLINE PROFILE] reconnecting to channel", chan)
self.client:orderChatJoin{channel=chan}
end
end
......@@ -23,7 +23,7 @@ local Client = require "profile-thread.Client"
local c = Client.new()
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, debug.traceback)
if not ok and res then
print("[PROFILE THREAD] error", res)
return false
......
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