IGridUserService.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using OpenMetaverse;
  30. namespace OpenSim.Services.Interfaces
  31. {
  32. /// <summary>
  33. /// Records user information specific to a grid but which is not part of a user's account.
  34. /// </summary>
  35. public class GridUserInfo
  36. {
  37. public string UserID;
  38. public UUID HomeRegionID;
  39. public Vector3 HomePosition;
  40. public Vector3 HomeLookAt;
  41. public UUID LastRegionID;
  42. public Vector3 LastPosition;
  43. public Vector3 LastLookAt;
  44. public bool Online;
  45. public DateTime Login;
  46. public DateTime Logout;
  47. public GridUserInfo() {}
  48. public GridUserInfo(Dictionary<string, object> kvp)
  49. {
  50. if (kvp.ContainsKey("UserID"))
  51. UserID = kvp["UserID"].ToString();
  52. if (kvp.ContainsKey("HomeRegionID"))
  53. UUID.TryParse(kvp["HomeRegionID"].ToString(), out HomeRegionID);
  54. if (kvp.ContainsKey("HomePosition"))
  55. Vector3.TryParse(kvp["HomePosition"].ToString(), out HomePosition);
  56. if (kvp.ContainsKey("HomeLookAt"))
  57. Vector3.TryParse(kvp["HomeLookAt"].ToString(), out HomeLookAt);
  58. if (kvp.ContainsKey("LastRegionID"))
  59. UUID.TryParse(kvp["LastRegionID"].ToString(), out LastRegionID);
  60. if (kvp.ContainsKey("LastPosition"))
  61. Vector3.TryParse(kvp["LastPosition"].ToString(), out LastPosition);
  62. if (kvp.ContainsKey("LastLookAt"))
  63. Vector3.TryParse(kvp["LastLookAt"].ToString(), out LastLookAt);
  64. if (kvp.ContainsKey("Login"))
  65. DateTime.TryParse(kvp["Login"].ToString(), out Login);
  66. if (kvp.ContainsKey("Logout"))
  67. DateTime.TryParse(kvp["Logout"].ToString(), out Logout);
  68. if (kvp.ContainsKey("Online"))
  69. Boolean.TryParse(kvp["Online"].ToString(), out Online);
  70. }
  71. public Dictionary<string, object> ToKeyValuePairs()
  72. {
  73. Dictionary<string, object> result = new Dictionary<string, object>();
  74. result["UserID"] = UserID;
  75. result["HomeRegionID"] = HomeRegionID.ToString();
  76. result["HomePosition"] = HomePosition.ToString();
  77. result["HomeLookAt"] = HomeLookAt.ToString();
  78. result["LastRegionID"] = LastRegionID.ToString();
  79. result["LastPosition"] = LastPosition.ToString();
  80. result["LastLookAt"] = LastLookAt.ToString();
  81. result["Online"] = Online.ToString();
  82. result["Login"] = Login.ToString();
  83. result["Logout"] = Logout.ToString();
  84. return result;
  85. }
  86. }
  87. public interface IGridUserService
  88. {
  89. GridUserInfo LoggedIn(string userID);
  90. bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt);
  91. bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt);
  92. bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt);
  93. GridUserInfo GetGridUserInfo(string userID);
  94. }
  95. }