From 4e5c896c7053b5c0a7eaaea4dd8c46204f6f4bba Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 21 Dec 2007 05:31:13 +0000 Subject: [PATCH] * InstantMessage() uses the recipient UUID as the SessionID to make IM sessions persistent by default * Cleaning some cruft out of TestClient, attempting to fix a TestClient IM bug on Mono git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1542 52acb1d6-8a22-11de-b505-999d5b087335 --- libsecondlife/AgentManager.cs | 52 +++++++++++-------- libsecondlife/Settings.cs | 4 +- .../examples/TestClient/ClientManager.cs | 6 +-- .../Commands/System/SetMasterCommand.cs | 6 +-- .../examples/TestClient/TestClient.cs | 16 +++--- 5 files changed, 45 insertions(+), 39 deletions(-) diff --git a/libsecondlife/AgentManager.cs b/libsecondlife/AgentManager.cs index e7da9bd9..947bf5d3 100644 --- a/libsecondlife/AgentManager.cs +++ b/libsecondlife/AgentManager.cs @@ -965,7 +965,7 @@ namespace libsecondlife /// Text message being sent public void InstantMessage(LLUUID target, string message) { - InstantMessage(Name, target, message, LLUUID.Random(), + InstantMessage(Name, target, message, target, InstantMessageDialog.MessageFromAgent, InstantMessageOnline.Offline, this.SimPosition, LLUUID.Zero, new byte[0]); } @@ -1028,31 +1028,39 @@ namespace libsecondlife InstantMessageDialog dialog, InstantMessageOnline offline, LLVector3 position, LLUUID regionID, byte[] binaryBucket) { - ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); + if (target != LLUUID.Zero) + { + ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); - im.AgentData.AgentID = Client.Self.AgentID; - im.AgentData.SessionID = Client.Self.SessionID; + im.AgentData.AgentID = Client.Self.AgentID; + im.AgentData.SessionID = Client.Self.SessionID; - im.MessageBlock.Dialog = (byte)dialog; - im.MessageBlock.FromAgentName = Helpers.StringToField(fromName); - im.MessageBlock.FromGroup = false; - im.MessageBlock.ID = imSessionID; - im.MessageBlock.Message = Helpers.StringToField(message); - im.MessageBlock.Offline = (byte)offline; - im.MessageBlock.ToAgentID = target; + im.MessageBlock.Dialog = (byte)dialog; + im.MessageBlock.FromAgentName = Helpers.StringToField(fromName); + im.MessageBlock.FromGroup = false; + im.MessageBlock.ID = imSessionID; + im.MessageBlock.Message = Helpers.StringToField(message); + im.MessageBlock.Offline = (byte)offline; + im.MessageBlock.ToAgentID = target; - if (binaryBucket != null) - im.MessageBlock.BinaryBucket = binaryBucket; + if (binaryBucket != null) + im.MessageBlock.BinaryBucket = binaryBucket; + else + im.MessageBlock.BinaryBucket = new byte[0]; + + // These fields are mandatory, even if we don't have valid values for them + im.MessageBlock.Position = LLVector3.Zero; + //TODO: Allow region id to be correctly set by caller or fetched from Client.* + im.MessageBlock.RegionID = regionID; + + // Send the message + Client.Network.SendPacket(im); + } else - im.MessageBlock.BinaryBucket = new byte[0]; - - // These fields are mandatory, even if we don't have valid values for them - im.MessageBlock.Position = LLVector3.Zero; - //TODO: Allow region id to be correctly set by caller or fetched from Client.* - im.MessageBlock.RegionID = regionID; - - // Send the message - Client.Network.SendPacket(im); + { + Client.Log(String.Format("Suppressing instant message \"{0}\" to LLUUID.Zero", message), + Helpers.LogLevel.Error); + } } /// diff --git a/libsecondlife/Settings.cs b/libsecondlife/Settings.cs index c0b67bc2..c94fd954 100644 --- a/libsecondlife/Settings.cs +++ b/libsecondlife/Settings.cs @@ -42,11 +42,11 @@ namespace libsecondlife /// Main grid login server public const string AGNI_LOGIN_SERVER = "https://login.agni.lindenlab.com/cgi-bin/login.cgi"; /// Beta grid login server - public const string ADITI_LOGIN_SERVER = "https://login.aditi.lindenlab.com/cgi-bin/login.cgi"; + public const string ADITI_LOGIN_SERVER = "https://login.aditi.lindenlab.com/cgi-bin/login-llsd.cgi"; /// The relative directory where external resources are kept public const string RESOURCE_DIR = "libsl_data"; - /// XML-RPC login server to connect to + /// Login server to connect to public string LOGIN_SERVER = AGNI_LOGIN_SERVER; // Timeouts and Intervals diff --git a/libsecondlife/examples/TestClient/ClientManager.cs b/libsecondlife/examples/TestClient/ClientManager.cs index 6415bfa5..c1fe5ab6 100644 --- a/libsecondlife/examples/TestClient/ClientManager.cs +++ b/libsecondlife/examples/TestClient/ClientManager.cs @@ -206,7 +206,7 @@ namespace libsecondlife.TestClient { PrintPrompt(); string input = Console.ReadLine(); - DoCommandAll(input, null, null); + DoCommandAll(input, LLUUID.Zero); } foreach (SecondLife client in Clients.Values) @@ -234,7 +234,7 @@ namespace libsecondlife.TestClient /// /// /// - public void DoCommandAll(string cmd, LLUUID fromAgentID, LLUUID imSessionID) + public void DoCommandAll(string cmd, LLUUID fromAgentID) { string[] tokens = cmd.Trim().Split(new char[] { ' ', '\t' }); string firstToken = tokens[0].ToLower(); @@ -261,7 +261,7 @@ namespace libsecondlife.TestClient Dictionary clientsCopy = new Dictionary(Clients); foreach (TestClient client in clientsCopy.Values) - client.DoCommand(cmd, fromAgentID, imSessionID); + client.DoCommand(cmd, fromAgentID); } } diff --git a/libsecondlife/examples/TestClient/Commands/System/SetMasterCommand.cs b/libsecondlife/examples/TestClient/Commands/System/SetMasterCommand.cs index ea8b55c3..268dfe01 100644 --- a/libsecondlife/examples/TestClient/Commands/System/SetMasterCommand.cs +++ b/libsecondlife/examples/TestClient/Commands/System/SetMasterCommand.cs @@ -49,10 +49,8 @@ namespace libsecondlife.TestClient } // Send an Online-only IM to the new master - Client.Self.InstantMessage(Client.Self.Name, Client.MasterKey, - "You are now my master. IM me with \"help\" for a command list.", LLUUID.Random(), - InstantMessageDialog.MessageFromAgent, InstantMessageOnline.Online, Client.Self.SimPosition, - Client.Network.CurrentSim.ID, new byte[0]); + Client.Self.InstantMessage( + Client.MasterKey, "You are now my master. IM me with \"help\" for a command list."); return String.Format("Master set to {0} ({1})", masterName, Client.MasterKey.ToString()); } diff --git a/libsecondlife/examples/TestClient/TestClient.cs b/libsecondlife/examples/TestClient/TestClient.cs index 9eee8e4e..d700dd02 100644 --- a/libsecondlife/examples/TestClient/TestClient.cs +++ b/libsecondlife/examples/TestClient/TestClient.cs @@ -85,7 +85,7 @@ namespace libsecondlife.TestClient } //breaks up large responses to deal with the max IM size - private void SendResponseIM(SecondLife client, LLUUID fromAgentID, string data, LLUUID imSessionID) + private void SendResponseIM(SecondLife client, LLUUID fromAgentID, string data) { for ( int i = 0 ; i < data.Length ; i += 1024 ) { int y; @@ -98,11 +98,11 @@ namespace libsecondlife.TestClient y = 1023; } string message = data.Substring(i, y); - client.Self.InstantMessage(fromAgentID, message, imSessionID); + client.Self.InstantMessage(fromAgentID, message); } } - public void DoCommand(string cmd, LLUUID fromAgentID, LLUUID imSessionID) + public void DoCommand(string cmd, LLUUID fromAgentID) { string[] tokens; @@ -125,7 +125,7 @@ namespace libsecondlife.TestClient cmd += tokens[i] + " "; } - ClientManager.DoCommandAll(cmd, fromAgentID, imSessionID); + ClientManager.DoCommandAll(cmd, fromAgentID); return; } @@ -140,11 +140,11 @@ namespace libsecondlife.TestClient { Console.WriteLine(response); - if (fromAgentID != null && Network.Connected) + if (fromAgentID != LLUUID.Zero && Network.Connected) { // IMs don't like \r\n line endings, clean them up first - response = response.Replace("\r", ""); - SendResponseIM(this, fromAgentID, response, imSessionID); + response = response.Replace("\r", String.Empty); + SendResponseIM(this, fromAgentID, response); } } } @@ -221,7 +221,7 @@ namespace libsecondlife.TestClient im.Dialog == InstantMessageDialog.MessageFromAgent || im.Dialog == InstantMessageDialog.MessageFromObject) { - DoCommand(im.Message, im.FromAgentID, im.IMSessionID); + DoCommand(im.Message, im.FromAgentID); } }