From a3f8809d2b89eb0cc6c478e8297580a19f4b2a68 Mon Sep 17 00:00:00 2001 From: Date: Mon, 2 Nov 2009 02:25:34 +0000 Subject: [PATCH] * Added Simulator property to ChatEventArgs * IRCGateway: Fixed a parsing error in non rfc-complient IRC PRIVMSG messages git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@3202 52acb1d6-8a22-11de-b505-999d5b087335 --- OpenMetaverse/AgentManager.cs | 8 ++++++-- Programs/examples/IRCGateway/IRCClient.cs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/OpenMetaverse/AgentManager.cs b/OpenMetaverse/AgentManager.cs index f52152e9..4b7e66e5 100644 --- a/OpenMetaverse/AgentManager.cs +++ b/OpenMetaverse/AgentManager.cs @@ -3167,7 +3167,7 @@ namespace OpenMetaverse ChatFromSimulatorPacket chat = (ChatFromSimulatorPacket)packet; - OnChat(new ChatEventArgs(Utils.BytesToString(chat.ChatData.Message), + OnChat(new ChatEventArgs(simulator, Utils.BytesToString(chat.ChatData.Message), (ChatAudibleLevel)chat.ChatData.Audible, (ChatType)chat.ChatData.ChatType, (ChatSourceType)chat.ChatData.SourceType, @@ -3979,6 +3979,7 @@ namespace OpenMetaverse /// public class ChatEventArgs : EventArgs { + private readonly Simulator m_Simulator; private readonly string m_Message; private readonly ChatAudibleLevel m_AudibleLevel; private readonly ChatType m_Type; @@ -3988,6 +3989,8 @@ namespace OpenMetaverse private readonly UUID m_OwnerID; private readonly Vector3 m_Position; + /// Get the simulator sending the message + public Simulator Simulator { get { return m_Simulator; } } /// Get the message sent public string Message { get { return m_Message; } } /// Get the audible level of the message @@ -4016,9 +4019,10 @@ namespace OpenMetaverse /// The ID of the agent or object sending the message /// The ID of the object owner, or the agent ID sending the message /// The position of the agent or object sending the message - public ChatEventArgs(string message, ChatAudibleLevel audible, ChatType type, + public ChatEventArgs(Simulator simulator, string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourceType, string fromName, UUID sourceId, UUID ownerid, Vector3 position) { + this.m_Simulator = simulator; this.m_Message = message; this.m_AudibleLevel = audible; this.m_Type = type; diff --git a/Programs/examples/IRCGateway/IRCClient.cs b/Programs/examples/IRCGateway/IRCClient.cs index 50e15c30..0efadff4 100644 --- a/Programs/examples/IRCGateway/IRCClient.cs +++ b/Programs/examples/IRCGateway/IRCClient.cs @@ -138,7 +138,7 @@ public class IRCClient if (OnMessage != null) { int nameIndex = words[0].IndexOf('!'); - string name = words[0].Substring(1, nameIndex - 1); + string name = nameIndex > 0 ? words[0].Substring(1, nameIndex - 1) : words[0]; string address = words[0].Substring(nameIndex + 1); OnMessage(words[2], name, address, lines[i].Substring(lines[i].IndexOf(":", 1) + 1)); }