GridServer.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 libsecondlife;
  30. namespace OpenSim
  31. {
  32. /// <summary>
  33. /// Handles connection to Grid Servers.
  34. /// also Sim to Sim connections?
  35. /// </summary>
  36. public class GridServer :IGridServer
  37. {
  38. public List<Logon> Sessions = new List<Logon>(); //should change to something other than logon classes?
  39. public GridServer()
  40. {
  41. Sessions = new List<Logon>();
  42. }
  43. public bool RequestConnection(RegionInfo myRegion)
  44. {
  45. return true;
  46. }
  47. public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
  48. {
  49. //For Grid use:
  50. //should check to see if it is a teleportation, if so then we should be expecting this session, agent. (?)
  51. //if not check with User server/ login server that it is authorised.
  52. //but for now we are running local
  53. AuthenticateResponse user = new AuthenticateResponse();
  54. lock(this.Sessions)
  55. {
  56. for(int i = 0; i < Sessions.Count; i++)
  57. {
  58. if((Sessions[i].Agent == agentID) && (Sessions[i].Session == sessionID))
  59. {
  60. user.Authorised = true;
  61. user.LogonInfo = Sessions[i];
  62. }
  63. }
  64. }
  65. return(user);
  66. }
  67. public UUIDBlock RequestUUIDBlock()
  68. {
  69. UUIDBlock uuidBlock = new UUIDBlock();
  70. return(uuidBlock);
  71. }
  72. public RegionInfo[] RequestNeighbours()
  73. {
  74. return(null);
  75. }
  76. /// <summary>
  77. /// used by the local login server to inform us of new sessions
  78. /// </summary>
  79. /// <param name="session"></param>
  80. public void AddNewSession(Logon session)
  81. {
  82. lock(this.Sessions)
  83. {
  84. this.Sessions.Add(session);
  85. }
  86. }
  87. }
  88. public interface IGridServer
  89. {
  90. bool RequestConnection(RegionInfo myRegion);
  91. UUIDBlock RequestUUIDBlock();
  92. RegionInfo[] RequestNeighbours();
  93. AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
  94. }
  95. public struct UUIDBlock
  96. {
  97. public LLUUID BlockStart;
  98. public LLUUID BlockEnd;
  99. }
  100. public class AuthenticateResponse
  101. {
  102. public bool Authorised;
  103. public Logon LogonInfo;
  104. public AuthenticateResponse()
  105. {
  106. }
  107. }
  108. }