LocalGridServer.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright (c) OpenSim project, http://sim.opensecondlife.org/
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. * * Redistributions of source code must retain the above copyright
  7. * notice, this list of conditions and the following disclaimer.
  8. * * Redistributions in binary form must reproduce the above copyright
  9. * notice, this list of conditions and the following disclaimer in the
  10. * documentation and/or other materials provided with the distribution.
  11. * * Neither the name of the <organization> nor the
  12. * names of its contributors may be used to endorse or promote products
  13. * derived from this software without specific prior written permission.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
  16. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  19. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. *
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Threading;
  30. using System.IO;
  31. using OpenSim.Framework.Interfaces;
  32. using OpenSim.Framework.Types;
  33. using libsecondlife;
  34. using Db4objects.Db4o;
  35. using Db4objects.Db4o.Query;
  36. namespace OpenSim.GridInterfaces.Local
  37. {
  38. /// <summary>
  39. ///
  40. /// </summary>
  41. ///
  42. public class LocalGridPlugin : IGridPlugin
  43. {
  44. public LocalGridPlugin()
  45. {
  46. }
  47. public IGridServer GetGridServer()
  48. {
  49. return(new LocalGridServer());
  50. }
  51. }
  52. public class LocalGridServer : LocalGridBase
  53. {
  54. public List<Login> Sessions = new List<Login>();
  55. public LocalGridServer()
  56. {
  57. Sessions = new List<Login>();
  58. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Local Grid Server class created");
  59. }
  60. public override bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port)
  61. {
  62. return true;
  63. }
  64. public override string GetName()
  65. {
  66. return "Local";
  67. }
  68. public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
  69. {
  70. //we are running local
  71. AuthenticateResponse user = new AuthenticateResponse();
  72. lock(this.Sessions)
  73. {
  74. for(int i = 0; i < Sessions.Count; i++)
  75. {
  76. if((Sessions[i].Agent == agentID) && (Sessions[i].Session == sessionID))
  77. {
  78. user.Authorised = true;
  79. user.LoginInfo = Sessions[i];
  80. }
  81. }
  82. }
  83. return(user);
  84. }
  85. public override bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
  86. {
  87. return(true);
  88. }
  89. public override UUIDBlock RequestUUIDBlock()
  90. {
  91. UUIDBlock uuidBlock = new UUIDBlock();
  92. return(uuidBlock);
  93. }
  94. public override NeighbourInfo[] RequestNeighbours()
  95. {
  96. return null;
  97. }
  98. public override void SetServerInfo(string ServerUrl, string SendKey, string RecvKey)
  99. {
  100. }
  101. public override void Close()
  102. {
  103. }
  104. /// <summary>
  105. /// used by the local login server to inform us of new sessions
  106. /// </summary>
  107. /// <param name="session"></param>
  108. public override void AddNewSession(Login session)
  109. {
  110. lock(this.Sessions)
  111. {
  112. this.Sessions.Add(session);
  113. }
  114. }
  115. }
  116. public class AssetUUIDQuery : Predicate
  117. {
  118. private LLUUID _findID;
  119. public AssetUUIDQuery(LLUUID find)
  120. {
  121. _findID = find;
  122. }
  123. public bool Match(AssetStorage asset)
  124. {
  125. return (asset.UUID == _findID);
  126. }
  127. }
  128. }