DB4oGridData.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using OpenGrid.Framework.Data;
  5. using libsecondlife;
  6. namespace OpenGrid.Framework.Data.DB4o
  7. {
  8. class DB4oGridData : IGridData
  9. {
  10. DB4oGridManager manager;
  11. public void Initialise() {
  12. manager = new DB4oGridManager("gridserver.yap");
  13. }
  14. public SimProfileData GetProfileByHandle(ulong handle) {
  15. lock (manager.simProfiles)
  16. {
  17. foreach (LLUUID UUID in manager.simProfiles.Keys)
  18. {
  19. if (manager.simProfiles[UUID].regionHandle == handle)
  20. {
  21. return manager.simProfiles[UUID];
  22. }
  23. }
  24. }
  25. throw new Exception("Unable to find profile with handle (" + handle.ToString() + ")");
  26. }
  27. public SimProfileData GetProfileByLLUUID(LLUUID uuid)
  28. {
  29. lock (manager.simProfiles)
  30. {
  31. if (manager.simProfiles.ContainsKey(uuid))
  32. return manager.simProfiles[uuid];
  33. }
  34. throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + ")");
  35. }
  36. public DataResponse AddProfile(SimProfileData profile)
  37. {
  38. lock (manager.simProfiles)
  39. {
  40. if (manager.AddRow(profile))
  41. {
  42. return DataResponse.RESPONSE_OK;
  43. }
  44. else
  45. {
  46. return DataResponse.RESPONSE_ERROR;
  47. }
  48. }
  49. }
  50. public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) {
  51. if (manager.simProfiles[uuid].regionRecvKey == key)
  52. return true;
  53. return false;
  54. }
  55. public void Close()
  56. {
  57. manager = null;
  58. }
  59. public string getName()
  60. {
  61. return "DB4o Grid Provider";
  62. }
  63. public string getVersion()
  64. {
  65. return "0.1";
  66. }
  67. }
  68. }