RegionCommsListener.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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.Framework
  31. {
  32. /// <summary>
  33. /// Sandbox mode region comms listener. There is one of these per region
  34. /// </summary>
  35. public class RegionCommsListener : IRegionCommsListener
  36. {
  37. public string debugRegionName = String.Empty;
  38. private AcknowledgeAgentCross handlerAcknowledgeAgentCrossed = null; // OnAcknowledgeAgentCrossed;
  39. private AcknowledgePrimCross handlerAcknowledgePrimCrossed = null; // OnAcknowledgePrimCrossed;
  40. private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion;
  41. private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
  42. private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
  43. private GenericCall2 handlerExpectChildAgent = null; // OnExpectChildAgent;
  44. private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser
  45. private UpdateNeighbours handlerNeighboursUpdate = null; // OnNeighboursUpdate;
  46. // private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
  47. private LogOffUser handlerLogOffUser = null;
  48. private GetLandData handlerGetLandData = null;
  49. #region IRegionCommsListener Members
  50. public event ExpectUserDelegate OnExpectUser;
  51. public event GenericCall2 OnExpectChildAgent;
  52. public event AgentCrossing OnAvatarCrossingIntoRegion;
  53. public event PrimCrossing OnPrimCrossingIntoRegion;
  54. public event UpdateNeighbours OnNeighboursUpdate;
  55. public event AcknowledgeAgentCross OnAcknowledgeAgentCrossed;
  56. public event AcknowledgePrimCross OnAcknowledgePrimCrossed;
  57. public event CloseAgentConnection OnCloseAgentConnection;
  58. public event ChildAgentUpdate OnChildAgentUpdate;
  59. public event LogOffUser OnLogOffUser;
  60. public event GetLandData OnGetLandData;
  61. #endregion
  62. /// <summary>
  63. ///
  64. /// </summary>
  65. /// <param name="agent"></param>
  66. /// <returns></returns>
  67. public virtual bool TriggerExpectUser(AgentCircuitData agent)
  68. {
  69. handlerExpectUser = OnExpectUser;
  70. if (handlerExpectUser != null)
  71. {
  72. handlerExpectUser(agent);
  73. return true;
  74. }
  75. return false;
  76. }
  77. // From User Server
  78. public virtual void TriggerLogOffUser(UUID agentID, UUID RegionSecret, string message)
  79. {
  80. handlerLogOffUser = OnLogOffUser;
  81. if (handlerLogOffUser != null)
  82. {
  83. handlerLogOffUser(agentID, RegionSecret, message);
  84. }
  85. }
  86. public virtual bool TriggerChildAgentUpdate(ChildAgentDataUpdate cAgentData)
  87. {
  88. handlerChildAgentUpdate = OnChildAgentUpdate;
  89. if (handlerChildAgentUpdate != null)
  90. {
  91. handlerChildAgentUpdate(cAgentData);
  92. return true;
  93. }
  94. return false;
  95. }
  96. public virtual bool TriggerExpectAvatarCrossing(UUID agentID, Vector3 position, bool isFlying)
  97. {
  98. handlerAvatarCrossingIntoRegion = OnAvatarCrossingIntoRegion;
  99. if (handlerAvatarCrossingIntoRegion != null)
  100. {
  101. handlerAvatarCrossingIntoRegion(agentID, position, isFlying);
  102. return true;
  103. }
  104. return false;
  105. }
  106. public virtual bool TriggerAcknowledgeAgentCrossed(UUID agentID)
  107. {
  108. handlerAcknowledgeAgentCrossed = OnAcknowledgeAgentCrossed;
  109. if (handlerAcknowledgeAgentCrossed != null)
  110. {
  111. handlerAcknowledgeAgentCrossed(agentID);
  112. return true;
  113. }
  114. return false;
  115. }
  116. public virtual bool TriggerAcknowledgePrimCrossed(UUID primID)
  117. {
  118. handlerAcknowledgePrimCrossed = OnAcknowledgePrimCrossed;
  119. if (handlerAcknowledgePrimCrossed != null)
  120. {
  121. handlerAcknowledgePrimCrossed(primID);
  122. return true;
  123. }
  124. return false;
  125. }
  126. public virtual bool TriggerCloseAgentConnection(UUID agentID)
  127. {
  128. handlerCloseAgentConnection = OnCloseAgentConnection;
  129. if (handlerCloseAgentConnection != null)
  130. {
  131. handlerCloseAgentConnection(agentID);
  132. return true;
  133. }
  134. return false;
  135. }
  136. /// <summary>
  137. ///
  138. /// </summary>
  139. /// <remarks>TODO: Doesnt take any args??</remarks>
  140. /// <returns></returns>
  141. public virtual bool TriggerExpectChildAgent()
  142. {
  143. handlerExpectChildAgent = OnExpectChildAgent;
  144. if (handlerExpectChildAgent != null)
  145. {
  146. handlerExpectChildAgent();
  147. return true;
  148. }
  149. return false;
  150. }
  151. /// <summary>
  152. ///
  153. /// </summary>
  154. /// <remarks>Added to avoid a unused compiler warning on OnNeighboursUpdate, TODO: Check me</remarks>
  155. /// <param name="neighbours"></param>
  156. /// <returns></returns>
  157. public virtual bool TriggerOnNeighboursUpdate(List<RegionInfo> neighbours)
  158. {
  159. handlerNeighboursUpdate = OnNeighboursUpdate;
  160. if (handlerNeighboursUpdate != null)
  161. {
  162. handlerNeighboursUpdate(neighbours);
  163. return true;
  164. }
  165. return false;
  166. }
  167. public bool TriggerTellRegionToCloseChildConnection(UUID agentID)
  168. {
  169. handlerCloseAgentConnection = OnCloseAgentConnection;
  170. if (handlerCloseAgentConnection != null)
  171. return handlerCloseAgentConnection(agentID);
  172. return false;
  173. }
  174. public LandData TriggerGetLandData(uint x, uint y)
  175. {
  176. handlerGetLandData = OnGetLandData;
  177. if (handlerGetLandData != null)
  178. return handlerGetLandData(x, y);
  179. return null;
  180. }
  181. }
  182. }