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