madkit.chat
Class ChatAgent

java.lang.Object
  extended by madkit.kernel.AbstractAgent
      extended by madkit.kernel.Agent
          extended by madkit.chat.ChatAgent
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable

public class ChatAgent
extends Agent

Titre : Chat Agent for MadKit Description : The Agent itself, used to control every pieces of the project. Copyright : Copyright (c) 2002 Société : UMII

See Also:
Serialized Form

Constructor Summary
ChatAgent()
           
 
Method Summary
 void activate()
          This method is initially called when the micro-kernel registers the agent.
 void addChannelForChatter(java.lang.String newCh)
          Set the role of the chatter to "admin" or "chatter"
 boolean addCouple(java.lang.String name, Channel ch, int nbrUsers)
          Add a couple (Channelname,Channel) in the hashtable nameChannel
 boolean addCouple(java.lang.String nick, Chatter ch)
          Add a couple (Nickname,Chatter) in the hashtable nickChatter
 void allowFunctions()
          Allow or not to use chat functions if the chatter is normal or Admin
 boolean doesAdminExist()
          Answer true if an admin is detected, else false
 void end()
          This method is called by the agent micro-kernel at the end of the agent lifecycle.
 void endChannel(AgentAddress newAdmin)
           
 boolean filterChatMessage(java.lang.String s, Message m)
          Allows ChatAgent to filter its own command, return true if the message is a command
 void firstThingsToDo()
           
 java.lang.String getChannelAdminName(java.lang.String ch)
          Get the admin 's name from the channel's name
 int getChannelNbrUsers(java.lang.String chName)
          get the number of user for a selected channel
 java.lang.String[] getChannelsAdminNamesList()
          Get a string tab of the channels admins name
 java.lang.String[] getChannelsNamesList()
          Get a string tab of the channels names
 java.lang.String[] getChannelsNbrUsersList()
          Get a string tab of the channels numbers of users
 java.lang.String[] getChannelsTopicsList()
          Get a string tab of the channels topics
 java.lang.String getChannelTopic(java.lang.String ch)
          Get the topic from the channel's name
 java.lang.String getChatter()
           
 AgentAddress getChatterAddress(java.lang.String nickname)
          Get the AgentAddress from the chatter's nickname
 java.lang.String getChatterAddressInString(java.lang.String nickname)
          Get the AgentAddress from the chatter's nickname, return a String
 AgentAddress[] getChatterAddressList()
          Get a AgentAddress list of the chatter
 java.lang.String getChatterEmailInString(java.lang.String nickname)
          Get the E-Mail from the chatter's nickname, return a String
 Chatter[] getChatterListWhoseAreInAChannel(java.lang.String ch_)
          Get chatters AgentAddress List for a choosen channel, RETURN INSTANCES OF CHATTER !!
 java.lang.String getChatterNickInString(java.lang.String nickname)
          Get the E-Mail from the chatter's nickname, return a String
 java.lang.String getChatterRole(java.lang.String n)
          Get the role of the chatter to "admin" or "chatter"
 Chatter getChatterThanksAgentAddress(AgentAddress agAd)
          Get the chatter instance that correspond to the agent address
 java.lang.String[] getEmailList()
          Get a string tab of the chatters email
 java.lang.String[] getNamesList()
          Get a string tab of the chatters names
 java.lang.String[] getRoleList()
          Get a string tab of the chatters Role
 java.lang.String[] getTabChatter()
           
 void handleMessage(Message m)
           
 void incrChannelNbrUsers(java.lang.String chName)
          Increase the number of users of the selected channel by one
 void initGUI()
          This method is called by the specific external graphic system (as the G-Box) to ask the agent to prepare a graphical interface.
 boolean isAdmin(java.lang.String chan_, java.lang.String chat_)
          Say if chatter is the channel's admin
 boolean isChatterInChannel(java.lang.String nick_, java.lang.String ch_)
          Is chatter in this channel
 void live()
          This method defines the main behavior for threaded agents.
 void printAdrNick()
          Print all the couple (Nickname,AgentAddress)
 void println(java.lang.String s)
          Prints text information in a environment-independant way (GUI, console, ...)
 void printnameChannel()
          Print on the std output the nameChannel hashtable content
 void printnickChatter()
          Print on the std output the nickChatter hashtable content
 void printNickChatter()
          Print the nickChatter hashtable on the stdoutput
 void printTabString(java.lang.String[] tabStr)
           
 void removeChannel(java.lang.String n)
           
 boolean removeChatter(java.lang.String nickname)
          Remove the couple (Nickname,AgentAddress) in the hashtable, return true if the job is well done
 void sendAddChannel(java.lang.String chName)
          Send #ADDNEWCHANNEL msg
 void sendAdminHashtable(AgentAddress a)
          Not optimized method, send the content of the nickChatter hashtable
 void sendAdminHashtableObject(AgentAddress a)
          Optimized method, send the object : nickChatter hashtable
 void sendBan(java.lang.String n)
          Send #BAN msg
 void sendChannelHashtableObject(AgentAddress a)
          Optimized method, send the object : nickChatter hashtable
 void sendChatMessage(java.lang.String s)
           
 void sendChatMessage(java.lang.String s, java.lang.String channel)
           
 void sendGetTable()
          Send gettable msg
 void sendKick(java.lang.String n)
          Send #KICK msg
 void sendMAJNbrUsrersOfChannel(java.lang.String chName)
          Send #MAJNBRUSRCHANNEL msg
 void sendQuerry(AgentAddress ad, java.lang.String n)
          Send query msg
 void sendRemoveChannel(java.lang.String chName)
          Send #REMOVECHANNEL msg
 void sendToAllNoneAdmin()
          Send the hashtable thanks to the optimized method to all the none "Admin" chatter
 void sendTopic(java.lang.String n, java.lang.String t)
          Send #TOPIC msg
 void sendUnique()
          Send #UNIQUE msg
 void setChannelNbrUsers(java.lang.String chName, int nbr)
          Set the number of user for a selected channel
 void setChannelRole(java.lang.String n)
          Set the name of the admin to chatter for a chosen channel
 void setChatter(java.lang.String s)
           
 void setChatterRole(java.lang.String r)
          Set the role of the chatter to "admin" or "chatter"
 void upDateNickname()
          Update the chatter tNames textArea thanks to the nickChatter hashtable
 
Methods inherited from class madkit.kernel.Agent
connectAgencyToAgency, createPlace, createPlace, enableMobility, enableMobility, exitImmediatlyOnKill, getAgencyNamed, joinPlace, joinPlace, joinPlace, pause, receiveMessage, run, waitNextMessage, waitNextMessage
 
Methods inherited from class madkit.kernel.AbstractAgent
broadcastMessage, broadcastMessage, connectedWithCommunity, createGroup, createGroup, debug, disposeMyGUI, foundGroup, getAddress, getAgentInformation, getAgentsWithRole, getAgentsWithRole, getAgentWithRole, getAgentWithRole, getAvailableCommunities, getBean, getController, getCurrentKernelAddress, getDebug, getExistingGroups, getExistingGroups, getExistingRoles, getExistingRoles, getGroups, getGUIObject, getMessageBoxSize, getMyGroups, getMyGroups, getMyRoles, getMyRoles, getName, getRoles, hasGUI, isBelongingToGroup, isBelongingToGroup, isCommunity, isGroup, isGroup, isMemberOf, isMemberOf, isMessageBoxEmpty, isRole, isRole, joinGroup, killAgent, launchAgent, launchAgent, leaveGroup, leaveGroup, leaveRole, leaveRole, nextMessage, print, redisplayMyGUI, requestRole, requestRole, requestRole, restoreAgent, sendMessage, sendMessage, sendMessage, setBean, setController, setDebug, setGUIObject, setName, setOutput, setOutputWriter, windowClosing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChatAgent

public ChatAgent()
Method Detail

setChatter

public void setChatter(java.lang.String s)

getChatter

public java.lang.String getChatter()

getTabChatter

public java.lang.String[] getTabChatter()

initGUI

public void initGUI()
Description copied from class: AbstractAgent
This method is called by the specific external graphic system (as the G-Box) to ask the agent to prepare a graphical interface. The agent developper should use a setGUIObject(...) within this method, as well as other necessary initializations. If the developper does not overload this method, a vanilla text output might be used as the default interface.

Overrides:
initGUI in class AbstractAgent

activate

public void activate()
Description copied from class: AbstractAgent
This method is initially called when the micro-kernel registers the agent. Usually a good place to set up some initial groups and roles.

Overrides:
activate in class AbstractAgent

live

public void live()
Description copied from class: Agent
This method defines the main behavior for threaded agents.

Overrides:
live in class Agent

firstThingsToDo

public void firstThingsToDo()

end

public void end()
Description copied from class: AbstractAgent
This method is called by the agent micro-kernel at the end of the agent lifecycle. If the the agent is killed from the outside, it is the last opportunity for the agent to cleanly shutdown its operations.

Overrides:
end in class AbstractAgent

endChannel

public void endChannel(AgentAddress newAdmin)

isAdmin

public boolean isAdmin(java.lang.String chan_,
                       java.lang.String chat_)
Say if chatter is the channel's admin


println

public void println(java.lang.String s)
Description copied from class: AbstractAgent
Prints text information in a environment-independant way (GUI, console, ...)

Overrides:
println in class AbstractAgent

handleMessage

public void handleMessage(Message m)

printTabString

public void printTabString(java.lang.String[] tabStr)

allowFunctions

public void allowFunctions()
Allow or not to use chat functions if the chatter is normal or Admin


doesAdminExist

public boolean doesAdminExist()
Answer true if an admin is detected, else false


sendChatMessage

public void sendChatMessage(java.lang.String s)

sendChatMessage

public void sendChatMessage(java.lang.String s,
                            java.lang.String channel)

filterChatMessage

public boolean filterChatMessage(java.lang.String s,
                                 Message m)
Allows ChatAgent to filter its own command, return true if the message is a command


sendToAllNoneAdmin

public void sendToAllNoneAdmin()
Send the hashtable thanks to the optimized method to all the none "Admin" chatter


sendAdminHashtable

public void sendAdminHashtable(AgentAddress a)
Not optimized method, send the content of the nickChatter hashtable


sendAdminHashtableObject

public void sendAdminHashtableObject(AgentAddress a)
Optimized method, send the object : nickChatter hashtable


sendChannelHashtableObject

public void sendChannelHashtableObject(AgentAddress a)
Optimized method, send the object : nickChatter hashtable


upDateNickname

public void upDateNickname()
Update the chatter tNames textArea thanks to the nickChatter hashtable


printnickChatter

public void printnickChatter()
Print on the std output the nickChatter hashtable content


printnameChannel

public void printnameChannel()
Print on the std output the nameChannel hashtable content


addCouple

public boolean addCouple(java.lang.String nick,
                         Chatter ch)
Add a couple (Nickname,Chatter) in the hashtable nickChatter


setChatterRole

public void setChatterRole(java.lang.String r)
Set the role of the chatter to "admin" or "chatter"


addChannelForChatter

public void addChannelForChatter(java.lang.String newCh)
Set the role of the chatter to "admin" or "chatter"


getChatterRole

public java.lang.String getChatterRole(java.lang.String n)
Get the role of the chatter to "admin" or "chatter"


printNickChatter

public void printNickChatter()
Print the nickChatter hashtable on the stdoutput


getChatterAddress

public AgentAddress getChatterAddress(java.lang.String nickname)
Get the AgentAddress from the chatter's nickname


getChatterAddressList

public AgentAddress[] getChatterAddressList()
Get a AgentAddress list of the chatter


getChatterAddressInString

public java.lang.String getChatterAddressInString(java.lang.String nickname)
Get the AgentAddress from the chatter's nickname, return a String


getChatterEmailInString

public java.lang.String getChatterEmailInString(java.lang.String nickname)
Get the E-Mail from the chatter's nickname, return a String


getChatterNickInString

public java.lang.String getChatterNickInString(java.lang.String nickname)
Get the E-Mail from the chatter's nickname, return a String


getChatterThanksAgentAddress

public Chatter getChatterThanksAgentAddress(AgentAddress agAd)
Get the chatter instance that correspond to the agent address


isChatterInChannel

public boolean isChatterInChannel(java.lang.String nick_,
                                  java.lang.String ch_)
Is chatter in this channel


getNamesList

public java.lang.String[] getNamesList()
Get a string tab of the chatters names


getEmailList

public java.lang.String[] getEmailList()
Get a string tab of the chatters email


getRoleList

public java.lang.String[] getRoleList()
Get a string tab of the chatters Role


getChatterListWhoseAreInAChannel

public Chatter[] getChatterListWhoseAreInAChannel(java.lang.String ch_)
Get chatters AgentAddress List for a choosen channel, RETURN INSTANCES OF CHATTER !!


removeChatter

public boolean removeChatter(java.lang.String nickname)
Remove the couple (Nickname,AgentAddress) in the hashtable, return true if the job is well done


printAdrNick

public void printAdrNick()
Print all the couple (Nickname,AgentAddress)


addCouple

public boolean addCouple(java.lang.String name,
                         Channel ch,
                         int nbrUsers)
Add a couple (Channelname,Channel) in the hashtable nameChannel


getChannelTopic

public java.lang.String getChannelTopic(java.lang.String ch)
Get the topic from the channel's name


getChannelAdminName

public java.lang.String getChannelAdminName(java.lang.String ch)
Get the admin 's name from the channel's name


setChannelRole

public void setChannelRole(java.lang.String n)
Set the name of the admin to chatter for a chosen channel


setChannelNbrUsers

public void setChannelNbrUsers(java.lang.String chName,
                               int nbr)
Set the number of user for a selected channel


getChannelNbrUsers

public int getChannelNbrUsers(java.lang.String chName)
get the number of user for a selected channel


incrChannelNbrUsers

public void incrChannelNbrUsers(java.lang.String chName)
Increase the number of users of the selected channel by one


getChannelsNamesList

public java.lang.String[] getChannelsNamesList()
Get a string tab of the channels names


getChannelsTopicsList

public java.lang.String[] getChannelsTopicsList()
Get a string tab of the channels topics


getChannelsNbrUsersList

public java.lang.String[] getChannelsNbrUsersList()
Get a string tab of the channels numbers of users


getChannelsAdminNamesList

public java.lang.String[] getChannelsAdminNamesList()
Get a string tab of the channels admins name


removeChannel

public void removeChannel(java.lang.String n)

sendQuerry

public void sendQuerry(AgentAddress ad,
                       java.lang.String n)
Send query msg


sendGetTable

public void sendGetTable()
Send gettable msg


sendKick

public void sendKick(java.lang.String n)
Send #KICK msg


sendBan

public void sendBan(java.lang.String n)
Send #BAN msg


sendTopic

public void sendTopic(java.lang.String n,
                      java.lang.String t)
Send #TOPIC msg


sendUnique

public void sendUnique()
Send #UNIQUE msg


sendAddChannel

public void sendAddChannel(java.lang.String chName)
Send #ADDNEWCHANNEL msg


sendMAJNbrUsrersOfChannel

public void sendMAJNbrUsrersOfChannel(java.lang.String chName)
Send #MAJNBRUSRCHANNEL msg


sendRemoveChannel

public void sendRemoveChannel(java.lang.String chName)
Send #REMOVECHANNEL msg



Copyright © Madkit Team (O. Gutknecht, J. Ferber, F. Michel et al.) All Rights Reserved.