RegionCommsListener.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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 OpenSim 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 libsecondlife;
  30. namespace OpenSim.Framework
  31. {
  32. public class RegionCommsListener : IRegionCommsListener
  33. {
  34. public string debugRegionName = String.Empty;
  35. private AcknowledgeAgentCross handlerAcknowledgeAgentCrossed = null; // OnAcknowledgeAgentCrossed;
  36. private AcknowledgePrimCross handlerAcknowledgePrimCrossed = null; // OnAcknowledgePrimCrossed;
  37. private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion;
  38. private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
  39. private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
  40. private GenericCall2 handlerExpectChildAgent = null; // OnExpectChildAgent;
  41. private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
  42. private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser
  43. private UpdateNeighbours handlerNeighboursUpdate = null; // OnNeighboursUpdate;
  44. private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
  45. private RegionUp handlerRegionUp = null; // OnRegionUp;
  46. #region IRegionCommsListener Members
  47. public event ExpectUserDelegate OnExpectUser;
  48. public event ExpectPrimDelegate OnExpectPrim;
  49. public event GenericCall2 OnExpectChildAgent;
  50. public event AgentCrossing OnAvatarCrossingIntoRegion;
  51. public event PrimCrossing OnPrimCrossingIntoRegion;
  52. public event UpdateNeighbours OnNeighboursUpdate;
  53. public event AcknowledgeAgentCross OnAcknowledgeAgentCrossed;
  54. public event AcknowledgePrimCross OnAcknowledgePrimCrossed;
  55. public event CloseAgentConnection OnCloseAgentConnection;
  56. public event RegionUp OnRegionUp;
  57. public event ChildAgentUpdate OnChildAgentUpdate;
  58. #endregion
  59. /// <summary>
  60. ///
  61. /// </summary>
  62. /// <param name="agent"></param>
  63. /// <returns></returns>
  64. public virtual bool TriggerExpectUser(ulong regionHandle, AgentCircuitData agent)
  65. {
  66. handlerExpectUser = OnExpectUser;
  67. if (handlerExpectUser != null)
  68. {
  69. handlerExpectUser(regionHandle, agent);
  70. return true;
  71. }
  72. return false;
  73. }
  74. public virtual bool TriggerExpectPrim(ulong regionHandle, LLUUID primID, string objData, int XMLMethod)
  75. {
  76. handlerExpectPrim = OnExpectPrim;
  77. if (handlerExpectPrim != null)
  78. {
  79. handlerExpectPrim(regionHandle, primID, objData, XMLMethod);
  80. return true;
  81. }
  82. return false;
  83. }
  84. public virtual bool TriggerRegionUp(RegionInfo region)
  85. {
  86. handlerRegionUp = OnRegionUp;
  87. if (handlerRegionUp != null)
  88. {
  89. handlerRegionUp(region);
  90. return true;
  91. }
  92. return false;
  93. }
  94. public virtual bool TriggerChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData)
  95. {
  96. handlerChildAgentUpdate = OnChildAgentUpdate;
  97. if (handlerChildAgentUpdate != null)
  98. {
  99. handlerChildAgentUpdate(regionHandle, cAgentData);
  100. return true;
  101. }
  102. return false;
  103. }
  104. public virtual bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position,
  105. bool isFlying)
  106. {
  107. handlerAvatarCrossingIntoRegion = OnAvatarCrossingIntoRegion;
  108. if (handlerAvatarCrossingIntoRegion != null)
  109. {
  110. handlerAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying);
  111. return true;
  112. }
  113. return false;
  114. }
  115. public virtual bool TriggerExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position,
  116. bool isPhysical)
  117. {
  118. handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
  119. if (handlerPrimCrossingIntoRegion != null)
  120. {
  121. handlerPrimCrossingIntoRegion(regionHandle, primID, position, isPhysical);
  122. return true;
  123. }
  124. return false;
  125. }
  126. public virtual bool TriggerAcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID)
  127. {
  128. handlerAcknowledgeAgentCrossed = OnAcknowledgeAgentCrossed;
  129. if (handlerAcknowledgeAgentCrossed != null)
  130. {
  131. handlerAcknowledgeAgentCrossed(regionHandle, agentID);
  132. return true;
  133. }
  134. return false;
  135. }
  136. public virtual bool TriggerAcknowledgePrimCrossed(ulong regionHandle, LLUUID primID)
  137. {
  138. handlerAcknowledgePrimCrossed = OnAcknowledgePrimCrossed;
  139. if (handlerAcknowledgePrimCrossed != null)
  140. {
  141. handlerAcknowledgePrimCrossed(regionHandle, primID);
  142. return true;
  143. }
  144. return false;
  145. }
  146. public virtual bool TriggerCloseAgentConnection(ulong regionHandle, LLUUID agentID)
  147. {
  148. handlerCloseAgentConnection = OnCloseAgentConnection;
  149. if (handlerCloseAgentConnection != null)
  150. {
  151. handlerCloseAgentConnection(regionHandle, agentID);
  152. return true;
  153. }
  154. return false;
  155. }
  156. /// <summary>
  157. ///
  158. /// </summary>
  159. /// <remarks>TODO: Doesnt take any args??</remarks>
  160. /// <returns></returns>
  161. public virtual bool TriggerExpectChildAgent()
  162. {
  163. handlerExpectChildAgent = OnExpectChildAgent;
  164. if (handlerExpectChildAgent != null)
  165. {
  166. handlerExpectChildAgent();
  167. return true;
  168. }
  169. return false;
  170. }
  171. /// <summary>
  172. ///
  173. /// </summary>
  174. /// <remarks>Added to avoid a unused compiler warning on OnNeighboursUpdate, TODO: Check me</remarks>
  175. /// <param name="neighbours"></param>
  176. /// <returns></returns>
  177. public virtual bool TriggerOnNeighboursUpdate(List<RegionInfo> neighbours)
  178. {
  179. handlerNeighboursUpdate = OnNeighboursUpdate;
  180. if (handlerNeighboursUpdate != null)
  181. {
  182. handlerNeighboursUpdate(neighbours);
  183. return true;
  184. }
  185. return false;
  186. }
  187. public bool TriggerTellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID)
  188. {
  189. handlerCloseAgentConnection = OnCloseAgentConnection;
  190. if (handlerCloseAgentConnection != null)
  191. return handlerCloseAgentConnection(regionHandle, agentID);
  192. return false;
  193. }
  194. }
  195. }