RegionCommsListener.cs 8.4 KB

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