RegionCommsListener.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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 ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
  45. private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser
  46. private UpdateNeighbours handlerNeighboursUpdate = null; // OnNeighboursUpdate;
  47. private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
  48. private RegionUp handlerRegionUp = null; // OnRegionUp;
  49. private LogOffUser handlerLogOffUser = null;
  50. private GetLandData handlerGetLandData = null;
  51. #region IRegionCommsListener Members
  52. public event ExpectUserDelegate OnExpectUser;
  53. public event ExpectPrimDelegate OnExpectPrim;
  54. public event GenericCall2 OnExpectChildAgent;
  55. public event AgentCrossing OnAvatarCrossingIntoRegion;
  56. public event PrimCrossing OnPrimCrossingIntoRegion;
  57. public event UpdateNeighbours OnNeighboursUpdate;
  58. public event AcknowledgeAgentCross OnAcknowledgeAgentCrossed;
  59. public event AcknowledgePrimCross OnAcknowledgePrimCrossed;
  60. public event CloseAgentConnection OnCloseAgentConnection;
  61. public event RegionUp OnRegionUp;
  62. public event ChildAgentUpdate OnChildAgentUpdate;
  63. public event LogOffUser OnLogOffUser;
  64. public event GetLandData OnGetLandData;
  65. #endregion
  66. /// <summary>
  67. ///
  68. /// </summary>
  69. /// <param name="agent"></param>
  70. /// <returns></returns>
  71. public virtual bool TriggerExpectUser(AgentCircuitData agent)
  72. {
  73. handlerExpectUser = OnExpectUser;
  74. if (handlerExpectUser != null)
  75. {
  76. handlerExpectUser(agent);
  77. return true;
  78. }
  79. return false;
  80. }
  81. // From User Server
  82. public virtual void TriggerLogOffUser(UUID agentID, UUID RegionSecret, string message)
  83. {
  84. handlerLogOffUser = OnLogOffUser;
  85. if (handlerLogOffUser != null)
  86. {
  87. handlerLogOffUser(agentID, RegionSecret, message);
  88. }
  89. }
  90. public virtual bool TriggerExpectPrim(UUID primID, string objData, int XMLMethod)
  91. {
  92. handlerExpectPrim = OnExpectPrim;
  93. if (handlerExpectPrim != null)
  94. {
  95. handlerExpectPrim(primID, objData, XMLMethod);
  96. return true;
  97. }
  98. return false;
  99. }
  100. public virtual bool TriggerRegionUp(RegionInfo region)
  101. {
  102. handlerRegionUp = OnRegionUp;
  103. if (handlerRegionUp != null)
  104. {
  105. handlerRegionUp(region);
  106. return true;
  107. }
  108. return false;
  109. }
  110. public virtual bool TriggerChildAgentUpdate(ChildAgentDataUpdate cAgentData)
  111. {
  112. handlerChildAgentUpdate = OnChildAgentUpdate;
  113. if (handlerChildAgentUpdate != null)
  114. {
  115. handlerChildAgentUpdate(cAgentData);
  116. return true;
  117. }
  118. return false;
  119. }
  120. public virtual bool TriggerExpectAvatarCrossing(UUID agentID, Vector3 position, bool isFlying)
  121. {
  122. handlerAvatarCrossingIntoRegion = OnAvatarCrossingIntoRegion;
  123. if (handlerAvatarCrossingIntoRegion != null)
  124. {
  125. handlerAvatarCrossingIntoRegion(agentID, position, isFlying);
  126. return true;
  127. }
  128. return false;
  129. }
  130. public virtual bool TriggerExpectPrimCrossing(UUID primID, Vector3 position,
  131. bool isPhysical)
  132. {
  133. handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
  134. if (handlerPrimCrossingIntoRegion != null)
  135. {
  136. handlerPrimCrossingIntoRegion(primID, position, isPhysical);
  137. return true;
  138. }
  139. return false;
  140. }
  141. public virtual bool TriggerAcknowledgeAgentCrossed(UUID agentID)
  142. {
  143. handlerAcknowledgeAgentCrossed = OnAcknowledgeAgentCrossed;
  144. if (handlerAcknowledgeAgentCrossed != null)
  145. {
  146. handlerAcknowledgeAgentCrossed(agentID);
  147. return true;
  148. }
  149. return false;
  150. }
  151. public virtual bool TriggerAcknowledgePrimCrossed(UUID primID)
  152. {
  153. handlerAcknowledgePrimCrossed = OnAcknowledgePrimCrossed;
  154. if (handlerAcknowledgePrimCrossed != null)
  155. {
  156. handlerAcknowledgePrimCrossed(primID);
  157. return true;
  158. }
  159. return false;
  160. }
  161. public virtual bool TriggerCloseAgentConnection(UUID agentID)
  162. {
  163. handlerCloseAgentConnection = OnCloseAgentConnection;
  164. if (handlerCloseAgentConnection != null)
  165. {
  166. handlerCloseAgentConnection(agentID);
  167. return true;
  168. }
  169. return false;
  170. }
  171. /// <summary>
  172. ///
  173. /// </summary>
  174. /// <remarks>TODO: Doesnt take any args??</remarks>
  175. /// <returns></returns>
  176. public virtual bool TriggerExpectChildAgent()
  177. {
  178. handlerExpectChildAgent = OnExpectChildAgent;
  179. if (handlerExpectChildAgent != null)
  180. {
  181. handlerExpectChildAgent();
  182. return true;
  183. }
  184. return false;
  185. }
  186. /// <summary>
  187. ///
  188. /// </summary>
  189. /// <remarks>Added to avoid a unused compiler warning on OnNeighboursUpdate, TODO: Check me</remarks>
  190. /// <param name="neighbours"></param>
  191. /// <returns></returns>
  192. public virtual bool TriggerOnNeighboursUpdate(List<RegionInfo> neighbours)
  193. {
  194. handlerNeighboursUpdate = OnNeighboursUpdate;
  195. if (handlerNeighboursUpdate != null)
  196. {
  197. handlerNeighboursUpdate(neighbours);
  198. return true;
  199. }
  200. return false;
  201. }
  202. public bool TriggerTellRegionToCloseChildConnection(UUID agentID)
  203. {
  204. handlerCloseAgentConnection = OnCloseAgentConnection;
  205. if (handlerCloseAgentConnection != null)
  206. return handlerCloseAgentConnection(agentID);
  207. return false;
  208. }
  209. public LandData TriggerGetLandData(uint x, uint y)
  210. {
  211. handlerGetLandData = OnGetLandData;
  212. if (handlerGetLandData != null)
  213. return handlerGetLandData(x, y);
  214. return null;
  215. }
  216. }
  217. }