aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs
blob: d15e3439f8ed5777ccd4564b246748e6c3bb214e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.Text;
using OpenGrid.Framework.Data;
using libsecondlife;


namespace OpenGrid.Framework.Data.DB4o
{
    class DB4oGridData : IGridData
    {
        DB4oManager manager;

        public void Initialise() {
             manager = new DB4oManager("gridserver.yap");
        }

        public SimProfileData GetProfileByHandle(ulong handle) {
            lock (manager.profiles)
            {
                foreach (LLUUID UUID in manager.profiles.Keys)
                {
                    if (manager.profiles[UUID].regionHandle == handle)
                    {
                        return manager.profiles[UUID];
                    }
                }
            }
            throw new Exception("Unable to find profile with handle (" + handle.ToString() + ")");
        }

        public SimProfileData GetProfileByLLUUID(LLUUID uuid)
        {
            lock (manager.profiles)
            {
                if (manager.profiles.ContainsKey(uuid))
                    return manager.profiles[uuid];
            }
            throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + ")");
        }

        public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) {
            if (manager.profiles[uuid].regionRecvKey == key)
                return true;
            return false;
        }

        public void Close()
        {
            manager = null;
        }

        public string getName()
        {
            return "DB4o Grid Provider";
        }

        public string getVersion()
        {
            return "0.1";
        }
    }
}