DB4oGridData.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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[] GetProfilesInRange(uint a, uint b, uint c, uint d)
  15. {
  16. return null;
  17. }
  18. public SimProfileData GetProfileByHandle(ulong handle) {
  19. lock (manager.simProfiles)
  20. {
  21. foreach (LLUUID UUID in manager.simProfiles.Keys)
  22. {
  23. if (manager.simProfiles[UUID].regionHandle == handle)
  24. {
  25. return manager.simProfiles[UUID];
  26. }
  27. }
  28. }
  29. throw new Exception("Unable to find profile with handle (" + handle.ToString() + ")");
  30. }
  31. public SimProfileData GetProfileByLLUUID(LLUUID uuid)
  32. {
  33. lock (manager.simProfiles)
  34. {
  35. if (manager.simProfiles.ContainsKey(uuid))
  36. return manager.simProfiles[uuid];
  37. }
  38. throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + ")");
  39. }
  40. public DataResponse AddProfile(SimProfileData profile)
  41. {
  42. lock (manager.simProfiles)
  43. {
  44. if (manager.AddRow(profile))
  45. {
  46. return DataResponse.RESPONSE_OK;
  47. }
  48. else
  49. {
  50. return DataResponse.RESPONSE_ERROR;
  51. }
  52. }
  53. }
  54. public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) {
  55. if (manager.simProfiles[uuid].regionRecvKey == key)
  56. return true;
  57. return false;
  58. }
  59. public void Close()
  60. {
  61. manager = null;
  62. }
  63. public string getName()
  64. {
  65. return "DB4o Grid Provider";
  66. }
  67. public string getVersion()
  68. {
  69. return "0.1";
  70. }
  71. }
  72. }