OSChatMessage.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 OpenMetaverse;
  29. namespace OpenSim.Framework
  30. {
  31. public interface IEventArgs
  32. {
  33. IScene Scene { get; set; }
  34. IClientAPI Sender { get; set; }
  35. }
  36. /// <summary>
  37. /// ChatFromViewer Arguments
  38. /// </summary>
  39. public class OSChatMessage : EventArgs, IEventArgs
  40. {
  41. protected int m_channel;
  42. protected string m_from;
  43. protected string m_message;
  44. protected Vector3 m_position;
  45. protected IScene m_scene;
  46. protected IClientAPI m_sender;
  47. protected object m_senderObject;
  48. protected ChatTypeEnum m_type;
  49. protected UUID m_fromID;
  50. protected UUID m_toID;
  51. public OSChatMessage()
  52. {
  53. m_position = new Vector3();
  54. m_toID = UUID.Zero;
  55. }
  56. /// <summary>
  57. /// The message sent by the user
  58. /// </summary>
  59. public string Message
  60. {
  61. get { return m_message; }
  62. set { m_message = value; }
  63. }
  64. /// <summary>
  65. /// The type of message, eg say, shout, broadcast.
  66. /// </summary>
  67. public ChatTypeEnum Type
  68. {
  69. get { return m_type; }
  70. set { m_type = value; }
  71. }
  72. /// <summary>
  73. /// Which channel was this message sent on? Different channels may have different listeners. Public chat is on channel zero.
  74. /// </summary>
  75. public int Channel
  76. {
  77. get { return m_channel; }
  78. set { m_channel = value; }
  79. }
  80. /// <summary>
  81. /// The position of the sender at the time of the message broadcast.
  82. /// </summary>
  83. public Vector3 Position
  84. {
  85. get { return m_position; }
  86. set { m_position = value; }
  87. }
  88. /// <summary>
  89. /// The name of the sender (needed for scripts)
  90. /// </summary>
  91. public string From
  92. {
  93. get { return m_from; }
  94. set { m_from = value; }
  95. }
  96. /// <summary>
  97. /// The name of the sender (needed for scripts)
  98. /// </summary>
  99. public string To
  100. {
  101. get { return m_from; }
  102. set { m_from = value; }
  103. }
  104. #region IEventArgs Members
  105. /// TODO: Sender and SenderObject should just be Sender and of
  106. /// type IChatSender
  107. /// <summary>
  108. /// The client responsible for sending the message, or null.
  109. /// </summary>
  110. public IClientAPI Sender
  111. {
  112. get { return m_sender; }
  113. set { m_sender = value; }
  114. }
  115. /// <summary>
  116. /// The object responsible for sending the message, or null.
  117. /// </summary>
  118. public object SenderObject
  119. {
  120. get { return m_senderObject; }
  121. set { m_senderObject = value; }
  122. }
  123. public UUID SenderUUID
  124. {
  125. get { return m_fromID; }
  126. set { m_fromID = value; }
  127. }
  128. /// <summary>
  129. /// The single recipient or all if not set.
  130. /// </summary>
  131. public UUID TargetUUID
  132. {
  133. get { return m_toID; }
  134. set { m_toID = value; }
  135. }
  136. /// <summary>
  137. ///
  138. /// </summary>
  139. public IScene Scene
  140. {
  141. get { return m_scene; }
  142. set { m_scene = value; }
  143. }
  144. public override string ToString()
  145. {
  146. return m_message;
  147. }
  148. #endregion
  149. }
  150. }