From 5c0a0bc2e0951745fd52f5c01f2ee2c0aee49a3a Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 3 Oct 2008 14:53:11 +0000 Subject: This changeset changes the way chat from client is routed: old way: each region module interested in chat from client had to - subscribe to scene.EventManager.OnNewClient - then in its OnNewClient delegate it would subscribe to client.OnChatFromViewer to capture chat messages coming new way: ChatModule is the only region module that uses the "old way" approach but is now forwarding all client chat via scene.EventManager.OnChatFromClient - each region module interested in chat from client now only subscribes to scene.EventManager.OnChatFromClient this not only simplifies code, but also allows us to substitute ChatModule with derived classes (ConciergeModule is going to be one example). Also, this changeset changes ChatFromViewer to ChatFromClient as it doesn't necessarily have to be a viewer that is a chat source. i've taken great care to only comment out those OnNewClient delegates that were only used for getting at the client chat --- hope it's not breaking anything. --- .../Modules/Avatar/Chat/IRCBridgeModule.cs | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs') diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs index eba65a9..5840cb2 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs @@ -93,6 +93,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat m_scenes.Add(scene); scene.EventManager.OnNewClient += OnNewClient; scene.EventManager.OnChatFromWorld += OnSimChat; + scene.EventManager.OnChatFromClient += OnSimChat; scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; } @@ -236,7 +237,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat if (avatar != null) { - fromName = avatar.Firstname + " " + avatar.Lastname; + fromName = avatar.Name; } // Try to reconnect to server if not connected @@ -277,21 +278,19 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat { try { - string clientName = String.Format("{0} {1}", client.FirstName, client.LastName); - - client.OnChatFromViewer += OnSimChat; + // client.OnChatFromViewer += OnSimChat; client.OnLogout += OnClientLoggedOut; client.OnConnectionClosed += OnClientLoggedOut; - if (clientName != m_last_new_user) + if (client.Name != m_last_new_user) { if ((m_irc.Enabled) && (m_irc.Connected)) { - m_log.DebugFormat("[IRC] {0} logging on", clientName); + m_log.DebugFormat("[IRC] {0} logging on", client.Name); m_irc.PrivMsg(m_irc.Nick, "Sim", - String.Format("notices {0} logging on", clientName)); + String.Format("notices {0} logging on", client.Name)); } - m_last_new_user = clientName; + m_last_new_user = client.Name; } } catch (Exception ex) @@ -343,21 +342,20 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat { if ((m_irc.Enabled) && (m_irc.Connected)) { - string clientName = String.Format("{0} {1}", client.FirstName, client.LastName); // handles simple case. May not work for hundred connecting in per second. // and the NewClients calles getting interleved // but filters out multiple reports - if (clientName != m_last_leaving_user) + if (client.Name != m_last_leaving_user) { Console.WriteLine("Avatar was seen logging out."); //Console.ReadLine(); Console.WriteLine(); - m_last_leaving_user = clientName; - m_irc.PrivMsg(m_irc.Nick, "Sim", String.Format("notices {0} logging out", clientName)); - m_log.InfoFormat("[IRC]: {0} logging out", clientName); + m_last_leaving_user = client.Name; + m_irc.PrivMsg(m_irc.Nick, "Sim", String.Format("notices {0} logging out", client.Name)); + m_log.InfoFormat("[IRC]: {0} logging out", client.Name); } - if (m_last_new_user == clientName) + if (m_last_new_user == client.Name) m_last_new_user = null; } } -- cgit v1.1