RegionCommsListener.cs 8.9 KB

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