OSChatMessage.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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_destination = UUID.Zero;
  51. public OSChatMessage()
  52. {
  53. m_position = new Vector3();
  54. }
  55. /// <summary>
  56. /// The message sent by the user
  57. /// </summary>
  58. public string Message
  59. {
  60. get { return m_message; }
  61. set { m_message = value; }
  62. }
  63. /// <summary>
  64. /// The type of message, eg say, shout, broadcast.
  65. /// </summary>
  66. public ChatTypeEnum Type
  67. {
  68. get { return m_type; }
  69. set { m_type = value; }
  70. }
  71. /// <summary>
  72. /// Which channel was this message sent on? Different channels may have different listeners. Public chat is on channel zero.
  73. /// </summary>
  74. public int Channel
  75. {
  76. get { return m_channel; }
  77. set { m_channel = value; }
  78. }
  79. /// <summary>
  80. /// The position of the sender at the time of the message broadcast.
  81. /// </summary>
  82. public Vector3 Position
  83. {
  84. get { return m_position; }
  85. set { m_position = value; }
  86. }
  87. /// <summary>
  88. /// The name of the sender (needed for scripts)
  89. /// </summary>
  90. public string From
  91. {
  92. get { return m_from; }
  93. set { m_from = value; }
  94. }
  95. #region IEventArgs Members
  96. /// TODO: Sender and SenderObject should just be Sender and of
  97. /// type IChatSender
  98. /// <summary>
  99. /// The client responsible for sending the message, or null.
  100. /// </summary>
  101. public IClientAPI Sender
  102. {
  103. get { return m_sender; }
  104. set { m_sender = value; }
  105. }
  106. /// <summary>
  107. /// The object responsible for sending the message, or null.
  108. /// </summary>
  109. public object SenderObject
  110. {
  111. get { return m_senderObject; }
  112. set { m_senderObject = value; }
  113. }
  114. public UUID SenderUUID
  115. {
  116. get { return m_fromID; }
  117. set { m_fromID = value; }
  118. }
  119. public UUID Destination
  120. {
  121. get { return m_destination; }
  122. set { m_destination = value; }
  123. }
  124. /// <summary>
  125. ///
  126. /// </summary>
  127. public IScene Scene
  128. {
  129. get { return m_scene; }
  130. set { m_scene = value; }
  131. }
  132. public override string ToString()
  133. {
  134. return m_message;
  135. }
  136. #endregion
  137. }
  138. }