Jafula
01-07-2009, 07:57 PM
I know a few addon developers lurk on these forums; hopefully you can help...
Jamba needs to know if your team members are online or not. If your team members are online, Jamba can send messages to them. Otherwise you get a lot of "Player Not Found" messages. Currently Jamba has a character "enabled" toggle. This toggle is confusing, but it works. I would like to remove this "enabled" setting and let Jamba decide whether your characters are online or not.
I have implemented the following:
When the addon is enabled, check to see if characters are online using UnitIsConnected( characterName ) - this is only good for party/raid AFAIK. If this check fails, try /who. I use SendWho( "-n"..characterName ) and catch the WHO_LIST_UPDATE event. Then I send a command to all characters that this character can see online telling them this character is online. Problem is, if all team members have just logging in, no one will know about anyone else, so the tell I am online command is useless. So I run both commands again in 15, 30 seconds. I also check for connection status when party members/leader changes. When a character logs out, they send a message to the others telling them they have gone offline.Other stuff:
I'm adding profile support; so you can set up solo modes / different teams easily. I know about LibWho2, but I could not get the library to function as I wanted and it has lot of extra code I won't use. What I have now doesn't work (not had much time to try it) and the friends frame who list pops up upon login.
Questions:
I'm not sure that the SetWhoToUI API command is going to be honored; I'm sure another addon can change it. Anyone know / have any experience with this? Will the WHO_LIST_UPDATE event always fire when who results are returned (seems to be controlled by the SetWhoToUI command)? Should I be checking for online status at other times? On a repeated timer? Other events? Should I even bother with the online checks( the enabled thing seems to work ok and this seems very flaky)?Relevant code (work in progress):
-- Called when the addon is enabled.
function AJM:OnEnable()
self:RegisterEvent( "WHO_LIST_UPDATE" )
self:RegisterEvent( "PLAYER_LOGOUT" )
self:RegisterEvent( "PARTY_LEADER_CHANGED" )
self:RegisterEvent( "PARTY_MEMBERS_CHANGED" )
-- Get team members online status to not connected.
self:__InitialiseTeamOnlineStatus()
-- Get the online status for other team members.
self:UpdateTeamOnlineStatus()
-- Kickstart the settings team list scroll frame.
self:__SettingsTeamListScrollRefresh()
-- Tell other members in the team that this character is online.
self:JambaSendCommandToTeam( AJM.COMMAND_CHARACTER_ONLINE, self.characterName, true )
-- Check online status again in 15 seconds.
self:ScheduleTimer( "UpdateTeamOnlineStatus", 15 )
-- Send I am online command to team again in 30 seconds.
self:ScheduleTimer( "JambaSendCommandToTeam", 30, AJM.COMMAND_CHARACTER_ONLINE, self.characterName, true )
end
-- Update team online status.
function AJM:UpdateTeamOnlineStatus()
for characterName, characterOrder in pairs( self.db.teamList ) do
self:__UpdateCharacterOnlineStatus( characterName )
end
end
-- Get a character's online status.
function AJM:__GetCharacterOnlineStatus( characterName )
return self.characterOnline[characterName]
end
-- Set a character's online status.
function AJM:__SetCharacterOnlineStatus( characterName, isOnline )
self.characterOnline[characterName] = isOnline
AJM:__SettingsTeamListScrollRefresh()
end
-- Update character online status.
function AJM:__UpdateCharacterOnlineStatus( characterName )
-- Check to see if it is in the same party/raid as this character.
if UnitIsConnected( characterName ) == 1 then
self:__SetCharacterOnlineStatus( characterName, true )
else
-- Does not appear to be in the same party/raid.
-- Make sure results are sent to the WHO_LIST_UPDATE event.
-- TODO: Does this popup the who dialog in the friends frame?
SetWhoToUI( 1 )
-- Check /who.
SendWho( "-n"..characterName )
end
end
function AJM:__InitialiseTeamOnlineStatus()
-- Set all characters online status to false.
for characterName, characterOrder in pairs( self.db.teamList ) do
self:__SetCharacterOnlineStatus( characterName, false )
end
end
function AJM:WHO_LIST_UPDATE()
-- TODO; which return from GetNumWhoResults to use?
local matchingCharacters, totalResults = GetNumWhoResults()
for iterateWhoResults = 1, totalResults do
local characterName, guildName, level, race, class, zone, classFileName = GetWhoInfo( iterateWhoResults )
if self:CharacterIsInTeam( characterName ) == true then
self:__SetCharacterOnlineStatus( characterName, true )
end
end
end
-- Player is logging out.
function AJM:PLAYER_LOGOUT()
-- Tell the other team members this player has logged out.
self:JambaSendCommandToTeam( AJM.COMMAND_CHARACTER_ONLINE, self.characterName, false )
end
-- Party leader changed.
function AJM:PARTY_LEADER_CHANGED()
-- Get the online status for other team members.
self:UpdateTeamOnlineStatus()
end
-- Party members changed.
function AJM:PARTY_MEMBERS_CHANGED()
-- Get the online status for other team members.
self:UpdateTeamOnlineStatus()
end
Any ideas / suggestions / criticism on this system greatly appreciated.
Jamba needs to know if your team members are online or not. If your team members are online, Jamba can send messages to them. Otherwise you get a lot of "Player Not Found" messages. Currently Jamba has a character "enabled" toggle. This toggle is confusing, but it works. I would like to remove this "enabled" setting and let Jamba decide whether your characters are online or not.
I have implemented the following:
When the addon is enabled, check to see if characters are online using UnitIsConnected( characterName ) - this is only good for party/raid AFAIK. If this check fails, try /who. I use SendWho( "-n"..characterName ) and catch the WHO_LIST_UPDATE event. Then I send a command to all characters that this character can see online telling them this character is online. Problem is, if all team members have just logging in, no one will know about anyone else, so the tell I am online command is useless. So I run both commands again in 15, 30 seconds. I also check for connection status when party members/leader changes. When a character logs out, they send a message to the others telling them they have gone offline.Other stuff:
I'm adding profile support; so you can set up solo modes / different teams easily. I know about LibWho2, but I could not get the library to function as I wanted and it has lot of extra code I won't use. What I have now doesn't work (not had much time to try it) and the friends frame who list pops up upon login.
Questions:
I'm not sure that the SetWhoToUI API command is going to be honored; I'm sure another addon can change it. Anyone know / have any experience with this? Will the WHO_LIST_UPDATE event always fire when who results are returned (seems to be controlled by the SetWhoToUI command)? Should I be checking for online status at other times? On a repeated timer? Other events? Should I even bother with the online checks( the enabled thing seems to work ok and this seems very flaky)?Relevant code (work in progress):
-- Called when the addon is enabled.
function AJM:OnEnable()
self:RegisterEvent( "WHO_LIST_UPDATE" )
self:RegisterEvent( "PLAYER_LOGOUT" )
self:RegisterEvent( "PARTY_LEADER_CHANGED" )
self:RegisterEvent( "PARTY_MEMBERS_CHANGED" )
-- Get team members online status to not connected.
self:__InitialiseTeamOnlineStatus()
-- Get the online status for other team members.
self:UpdateTeamOnlineStatus()
-- Kickstart the settings team list scroll frame.
self:__SettingsTeamListScrollRefresh()
-- Tell other members in the team that this character is online.
self:JambaSendCommandToTeam( AJM.COMMAND_CHARACTER_ONLINE, self.characterName, true )
-- Check online status again in 15 seconds.
self:ScheduleTimer( "UpdateTeamOnlineStatus", 15 )
-- Send I am online command to team again in 30 seconds.
self:ScheduleTimer( "JambaSendCommandToTeam", 30, AJM.COMMAND_CHARACTER_ONLINE, self.characterName, true )
end
-- Update team online status.
function AJM:UpdateTeamOnlineStatus()
for characterName, characterOrder in pairs( self.db.teamList ) do
self:__UpdateCharacterOnlineStatus( characterName )
end
end
-- Get a character's online status.
function AJM:__GetCharacterOnlineStatus( characterName )
return self.characterOnline[characterName]
end
-- Set a character's online status.
function AJM:__SetCharacterOnlineStatus( characterName, isOnline )
self.characterOnline[characterName] = isOnline
AJM:__SettingsTeamListScrollRefresh()
end
-- Update character online status.
function AJM:__UpdateCharacterOnlineStatus( characterName )
-- Check to see if it is in the same party/raid as this character.
if UnitIsConnected( characterName ) == 1 then
self:__SetCharacterOnlineStatus( characterName, true )
else
-- Does not appear to be in the same party/raid.
-- Make sure results are sent to the WHO_LIST_UPDATE event.
-- TODO: Does this popup the who dialog in the friends frame?
SetWhoToUI( 1 )
-- Check /who.
SendWho( "-n"..characterName )
end
end
function AJM:__InitialiseTeamOnlineStatus()
-- Set all characters online status to false.
for characterName, characterOrder in pairs( self.db.teamList ) do
self:__SetCharacterOnlineStatus( characterName, false )
end
end
function AJM:WHO_LIST_UPDATE()
-- TODO; which return from GetNumWhoResults to use?
local matchingCharacters, totalResults = GetNumWhoResults()
for iterateWhoResults = 1, totalResults do
local characterName, guildName, level, race, class, zone, classFileName = GetWhoInfo( iterateWhoResults )
if self:CharacterIsInTeam( characterName ) == true then
self:__SetCharacterOnlineStatus( characterName, true )
end
end
end
-- Player is logging out.
function AJM:PLAYER_LOGOUT()
-- Tell the other team members this player has logged out.
self:JambaSendCommandToTeam( AJM.COMMAND_CHARACTER_ONLINE, self.characterName, false )
end
-- Party leader changed.
function AJM:PARTY_LEADER_CHANGED()
-- Get the online status for other team members.
self:UpdateTeamOnlineStatus()
end
-- Party members changed.
function AJM:PARTY_MEMBERS_CHANGED()
-- Get the online status for other team members.
self:UpdateTeamOnlineStatus()
end
Any ideas / suggestions / criticism on this system greatly appreciated.