From 755ad9e3e0447b60299b08a18624064d1d64141b Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 4 Feb 2008 12:04:02 +0000 Subject: First part of avatar persistence, currently only really works in standalone mode (with accounts_authenticate set to true), it also only currently has a mysql database connector. (sqlite one will follow soon). It also uses the tribalmedia database system, so this needs checking to see if the old problems with mono have been fixed. To use, see the appearance section in opensim.ini.example, set "persist = true", then add the correct connection string for your database.(see mysql-AvatarAppearance.sql in share folder for a example of the table mysql table structure). This could possible be used in a very small grid, but would mean each region server would need to connect to the same mysql database. But the work to move the code to one of the grid servers shouldn't be too much. --- .../Communications/Cache/GridAssetClient.cs | 2 ++ .../Communications/RestClient/RestClient.cs | 1 + .../Framework/Data.MySQL/MySQLDatabaseMapper.cs | 9 ++++---- OpenSim/Framework/Data/OpenSimDataReader.cs | 4 ++-- OpenSim/Framework/Data/OpenSimDatabaseConnector.cs | 26 ++++++++++++++++++++-- OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs | 4 ++-- OpenSim/Framework/Data/OpenSimTableMapper.cs | 3 +-- .../Data/PrimitiveBaseShapeTableMapper.cs | 6 ++--- 8 files changed, 40 insertions(+), 15 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index cf54fa4..2f0727f 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -95,11 +95,13 @@ namespace OpenSim.Framework.Communications.Cache // RestClient rc = new RestClient(_assetServerUrl); MainLog.Instance.Verbose("ASSET", "Storing asset"); //rc.AddResourcePath("assets"); + // rc.RequestMethod = "POST"; // rc.Request(s); //MainLog.Instance.Verbose("ASSET", "Stored {0}", rc); MainLog.Instance.Verbose("ASSET", "Sending to " + _assetServerUrl + "/assets/"); RestObjectPoster.BeginPostObject(_assetServerUrl + "/assets/", asset); + } catch (Exception e) { diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs index e4da4dc..76bad64 100644 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -389,6 +389,7 @@ namespace OpenSim.Framework.Communications dst.Write(buf, 0, length); length = src.Read(buf, 0, 1024); } + _response = (HttpWebResponse) _request.GetResponse(); // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); diff --git a/OpenSim/Framework/Data.MySQL/MySQLDatabaseMapper.cs b/OpenSim/Framework/Data.MySQL/MySQLDatabaseMapper.cs index 275ce47..5d636bd 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLDatabaseMapper.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLDatabaseMapper.cs @@ -1,10 +1,11 @@ using System.Data.Common; using MySql.Data.MySqlClient; -// using TribalMedia.Framework.Data; + //using TribalMedia.Framework.Data; + -/* namespace OpenSim.Framework.Data.MySQL { + /* public class MySQLDatabaseMapper : OpenSimDatabaseConnector { public MySQLDatabaseMapper(string connectionString) @@ -22,6 +23,6 @@ namespace OpenSim.Framework.Data.MySQL { return "?" + fieldName; } - } + }*/ } -*/ + diff --git a/OpenSim/Framework/Data/OpenSimDataReader.cs b/OpenSim/Framework/Data/OpenSimDataReader.cs index c7b6470..d113f14 100644 --- a/OpenSim/Framework/Data/OpenSimDataReader.cs +++ b/OpenSim/Framework/Data/OpenSimDataReader.cs @@ -4,7 +4,7 @@ using System.Data; using System.Text; using libsecondlife; -/* + using TribalMedia.Framework.Data; namespace OpenSim.Framework.Data @@ -39,4 +39,4 @@ namespace OpenSim.Framework.Data } } } -*/ + diff --git a/OpenSim/Framework/Data/OpenSimDatabaseConnector.cs b/OpenSim/Framework/Data/OpenSimDatabaseConnector.cs index 155bdc1..aba9329 100644 --- a/OpenSim/Framework/Data/OpenSimDatabaseConnector.cs +++ b/OpenSim/Framework/Data/OpenSimDatabaseConnector.cs @@ -1,6 +1,8 @@ using System.Data; +using System.Data.Common; using libsecondlife; -/* +using MySql.Data.MySqlClient; + using TribalMedia.Framework.Data; namespace OpenSim.Framework.Data @@ -26,5 +28,25 @@ namespace OpenSim.Framework.Data return new OpenSimDataReader(reader); } } + + + public class MySQLDatabaseMapper : OpenSimDatabaseConnector + { + public MySQLDatabaseMapper(string connectionString) + : base(connectionString) + { + } + + public override DbConnection GetNewConnection() + { + MySqlConnection connection = new MySqlConnection(m_connectionString); + return connection; + } + + public override string CreateParamName(string fieldName) + { + return "?" + fieldName; + } + } } -*/ + diff --git a/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs b/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs index 8d5b9cf..269f863 100644 --- a/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs +++ b/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Data.Common; using System.Text; using libsecondlife; -/* + using TribalMedia.Framework.Data; namespace OpenSim.Framework.Data @@ -73,4 +73,4 @@ namespace OpenSim.Framework.Data } } } -*/ + diff --git a/OpenSim/Framework/Data/OpenSimTableMapper.cs b/OpenSim/Framework/Data/OpenSimTableMapper.cs index f596b45..e5deae0 100644 --- a/OpenSim/Framework/Data/OpenSimTableMapper.cs +++ b/OpenSim/Framework/Data/OpenSimTableMapper.cs @@ -1,5 +1,5 @@ using System.Data; -/* + using TribalMedia.Framework.Data; namespace OpenSim.Framework.Data @@ -11,4 +11,3 @@ namespace OpenSim.Framework.Data } } } -*/ diff --git a/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs b/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs index 227a98e..ec9689a 100644 --- a/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs +++ b/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs @@ -1,9 +1,9 @@ using System; using OpenSim.Framework; -//using TribalMedia.Framework.Data; +using TribalMedia.Framework.Data; using libsecondlife; -/* + namespace OpenSim.Framework.Data { public class PrimitiveBaseShapeRowMapper : BaseRowMapper @@ -142,4 +142,4 @@ namespace OpenSim.Framework.Data } } } -*/ + -- cgit v1.1