This changeset changes the way chat from client is routed:
old way: each region module interested in chat from client had to - subscribe to scene.EventManager.OnNewClient - then in its OnNewClient delegate it would subscribe to client.OnChatFromViewer to capture chat messages coming new way: ChatModule is the only region module that uses the "old way" approach but is now forwarding all client chat via scene.EventManager.OnChatFromClient - each region module interested in chat from client now only subscribes to scene.EventManager.OnChatFromClient this not only simplifies code, but also allows us to substitute ChatModule with derived classes (ConciergeModule is going to be one example). Also, this changeset changes ChatFromViewer to ChatFromClient as it doesn't necessarily have to be a viewer that is a chat source. i've taken great care to only comment out those OnNewClient delegates that were only used for getting at the client chat --- hope it's not breaking anything.0.6.0-stable
parent
8c55f3eaa6
commit
5c0a0bc2e0
|
@ -363,7 +363,7 @@ namespace OpenSim.Framework
|
|||
// [Obsolete("LLClientView Specific - Replace with more bare-bones arguments.")]
|
||||
event ImprovedInstantMessage OnInstantMessage;
|
||||
// [Obsolete("LLClientView Specific - Replace with more bare-bones arguments. Rename OnChat.")]
|
||||
event ChatMessage OnChatFromViewer;
|
||||
event ChatMessage OnChatFromClient;
|
||||
// [Obsolete("LLClientView Specific - Replace with more bare-bones arguments.")]
|
||||
event TextureRequest OnRequestTexture;
|
||||
// [Obsolete("LLClientView Specific - Remove bitbuckets. Adam, can you be more specific here.. as I don't see any bit buckets.")]
|
||||
|
|
|
@ -140,6 +140,11 @@ namespace OpenSim.Framework
|
|||
set { m_scene = value; }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return m_message;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,8 +124,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
private GenericMessage handlerGenericMessage = null;
|
||||
private RequestAvatarProperties handlerRequestAvatarProperties = null; //OnRequestAvatarProperties;
|
||||
private UpdateAvatarProperties handlerUpdateAvatarProperties = null; // OnUpdateAvatarProperties;
|
||||
private ChatMessage handlerChatFromViewer = null; //OnChatFromViewer;
|
||||
private ChatMessage handlerChatFromViewer2 = null; //OnChatFromViewer;
|
||||
private ChatMessage handlerChatFromClient = null; //OnChatFromClient;
|
||||
private ChatMessage handlerChatFromClient2 = null; //OnChatFromClient;
|
||||
private ImprovedInstantMessage handlerInstantMessage = null; //OnInstantMessage;
|
||||
private FriendActionDelegate handlerApproveFriendRequest = null; //OnApproveFriendRequest;
|
||||
private FriendshipTermination handlerTerminateFriendship = null; //OnTerminateFriendship;
|
||||
|
@ -833,7 +833,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
public event Action<IClientAPI> OnConnectionClosed;
|
||||
public event ViewerEffectEventHandler OnViewerEffect;
|
||||
public event ImprovedInstantMessage OnInstantMessage;
|
||||
public event ChatMessage OnChatFromViewer;
|
||||
public event ChatMessage OnChatFromClient;
|
||||
public event TextureRequest OnRequestTexture;
|
||||
public event RezObject OnRezObject;
|
||||
public event GenericCall4 OnDeRezObject;
|
||||
|
@ -4008,7 +4008,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
|
||||
int channel = inchatpack.ChatData.Channel;
|
||||
|
||||
if (OnChatFromViewer != null)
|
||||
if (OnChatFromClient != null)
|
||||
{
|
||||
OSChatMessage args = new OSChatMessage();
|
||||
args.Channel = channel;
|
||||
|
@ -4020,9 +4020,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
args.Scene = Scene;
|
||||
args.Sender = this;
|
||||
|
||||
handlerChatFromViewer = OnChatFromViewer;
|
||||
if (handlerChatFromViewer != null)
|
||||
handlerChatFromViewer(this, args);
|
||||
handlerChatFromClient = OnChatFromClient;
|
||||
if (handlerChatFromClient != null)
|
||||
handlerChatFromClient(this, args);
|
||||
}
|
||||
break;
|
||||
case PacketType.AvatarPropertiesUpdate:
|
||||
|
@ -4047,7 +4047,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
|
||||
int ch = rdialog.Data.ChatChannel;
|
||||
byte[] msg = rdialog.Data.ButtonLabel;
|
||||
if (OnChatFromViewer != null)
|
||||
if (OnChatFromClient != null)
|
||||
{
|
||||
OSChatMessage args = new OSChatMessage();
|
||||
args.Channel = ch;
|
||||
|
@ -4057,9 +4057,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
args.Position = new Vector3();
|
||||
args.Scene = Scene;
|
||||
args.Sender = this;
|
||||
handlerChatFromViewer2 = OnChatFromViewer;
|
||||
if (handlerChatFromViewer2 != null)
|
||||
handlerChatFromViewer2(this, args);
|
||||
handlerChatFromClient2 = OnChatFromClient;
|
||||
if (handlerChatFromClient2 != null)
|
||||
handlerChatFromClient2(this, args);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -64,8 +64,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
|||
{
|
||||
m_scenes.Add(scene);
|
||||
scene.EventManager.OnNewClient += OnNewClient;
|
||||
scene.EventManager.OnChatFromWorld += OnSimChat;
|
||||
scene.EventManager.OnChatBroadcast += OnSimBroadcast;
|
||||
scene.EventManager.OnChatFromWorld += OnChatFromWorld;
|
||||
scene.EventManager.OnChatBroadcast += OnChatBroadcast;
|
||||
}
|
||||
}
|
||||
|
||||
// wrap this in a try block so that defaults will work if
|
||||
|
@ -82,8 +83,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
|||
m_log.InfoFormat("[CHAT] initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName,
|
||||
m_whisperdistance, m_saydistance, m_shoutdistance);
|
||||
}
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
}
|
||||
|
@ -104,8 +103,89 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
|||
|
||||
#endregion
|
||||
|
||||
#region ISimChat Members
|
||||
public void OnSimBroadcast(Object sender, OSChatMessage c)
|
||||
|
||||
public void OnNewClient(IClientAPI client)
|
||||
{
|
||||
try
|
||||
{
|
||||
client.OnChatFromClient += OnChatFromClient;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.Error("[CHAT]: NewClient exception trap:" + ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnChatFromClient(Object sender, OSChatMessage e)
|
||||
{
|
||||
// redistribute to interested subscribers
|
||||
Scene scene = (Scene)e.Scene;
|
||||
scene.EventManager.TriggerOnChatFromClient(sender, e);
|
||||
|
||||
// early return if not on public or debug channel
|
||||
if (e.Channel != 0 && e.Channel != DEBUG_CHANNEL) return;
|
||||
|
||||
// sanity check:
|
||||
if (e.Sender == null)
|
||||
{
|
||||
m_log.ErrorFormat("[CHAT] OnChatFromClient from {0} has empty Sender field!", sender);
|
||||
return;
|
||||
}
|
||||
|
||||
string message = e.Message;
|
||||
if (e.Channel == DEBUG_CHANNEL) e.Type = ChatTypeEnum.DebugChannel;
|
||||
|
||||
ScenePresence avatar = scene.GetScenePresence(e.Sender.AgentId);
|
||||
Vector3 fromPos = avatar.AbsolutePosition;
|
||||
Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize,
|
||||
scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
|
||||
string fromName = avatar.Firstname + " " + avatar.Lastname;
|
||||
UUID fromID = e.Sender.AgentId;
|
||||
|
||||
DeliverChatToAvatars(fromPos, regionPos, fromID, fromName, e.Type, ChatSourceType.Agent, message);
|
||||
}
|
||||
|
||||
public void OnChatFromWorld(Object sender, OSChatMessage e)
|
||||
{
|
||||
Scene scene = (Scene) e.Scene;
|
||||
|
||||
// early return if not on public or debug channel
|
||||
if (e.Channel != 0 && e.Channel != DEBUG_CHANNEL) return;
|
||||
|
||||
// Filled in since it's easier than rewriting right now.
|
||||
Vector3 fromPos = e.Position;
|
||||
Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize,
|
||||
scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
|
||||
|
||||
string fromName = e.From;
|
||||
string message = e.Message;
|
||||
UUID fromID = e.SenderUUID;
|
||||
|
||||
if (e.Channel == DEBUG_CHANNEL)
|
||||
e.Type = ChatTypeEnum.DebugChannel;
|
||||
|
||||
DeliverChatToAvatars(fromPos, regionPos, fromID, fromName, e.Type, ChatSourceType.Object, message);
|
||||
}
|
||||
|
||||
protected void DeliverChatToAvatars(Vector3 pos, Vector3 regionPos, UUID uuid, string name,
|
||||
ChatTypeEnum chatType, ChatSourceType sourceType, string message)
|
||||
{
|
||||
// iterate over message
|
||||
if (message.Length >= 1000) // libomv limit
|
||||
message = message.Substring(0, 1000);
|
||||
|
||||
foreach (Scene s in m_scenes)
|
||||
{
|
||||
s.ForEachScenePresence(delegate(ScenePresence presence)
|
||||
{
|
||||
TrySendChatMessage(presence, pos, regionPos, uuid, name,
|
||||
chatType, message, sourceType);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void OnChatBroadcast(Object sender, OSChatMessage c)
|
||||
{
|
||||
// We only want to relay stuff on channel 0 and on the debug channel
|
||||
if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return;
|
||||
|
@ -153,83 +233,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
|||
});
|
||||
}
|
||||
|
||||
public void OnSimChat(Object sender, OSChatMessage e)
|
||||
{
|
||||
// early return if not on public or debug channel
|
||||
if (e.Channel != 0 && e.Channel != DEBUG_CHANNEL) return;
|
||||
|
||||
ScenePresence avatar = null;
|
||||
Scene scene = (Scene) e.Scene;
|
||||
|
||||
//TODO: Remove the need for this check
|
||||
if (scene == null)
|
||||
scene = m_scenes[0];
|
||||
|
||||
// Filled in since it's easier than rewriting right now.
|
||||
Vector3 fromPos = e.Position;
|
||||
Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize,
|
||||
scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
|
||||
|
||||
string fromName = e.From;
|
||||
string message = e.Message;
|
||||
UUID fromID = e.SenderUUID;
|
||||
|
||||
if (message.Length >= 1000) // libomv limit
|
||||
message = message.Substring(0, 1000);
|
||||
|
||||
if (e.Sender != null)
|
||||
{
|
||||
avatar = scene.GetScenePresence(e.Sender.AgentId);
|
||||
}
|
||||
|
||||
if (avatar != null)
|
||||
{
|
||||
fromPos = avatar.AbsolutePosition;
|
||||
regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize,
|
||||
scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
|
||||
fromName = avatar.Firstname + " " + avatar.Lastname;
|
||||
fromID = e.Sender.AgentId;
|
||||
}
|
||||
|
||||
if (e.Channel == DEBUG_CHANNEL)
|
||||
e.Type = ChatTypeEnum.DebugChannel;
|
||||
|
||||
// chat works by redistributing every incoming chat
|
||||
// message to each avatar in the scene
|
||||
foreach (Scene s in m_scenes)
|
||||
{
|
||||
s.ForEachScenePresence(
|
||||
delegate(ScenePresence presence)
|
||||
{
|
||||
if (e.Channel == DEBUG_CHANNEL)
|
||||
{
|
||||
TrySendChatMessage(presence, fromPos, regionPos,
|
||||
fromID, fromName, e.Type,
|
||||
message, ChatSourceType.Object);
|
||||
}
|
||||
else
|
||||
{
|
||||
TrySendChatMessage(presence, fromPos, regionPos,
|
||||
fromID, fromName, e.Type,
|
||||
message, ChatSourceType.Agent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void OnNewClient(IClientAPI client)
|
||||
{
|
||||
try
|
||||
{
|
||||
client.OnChatFromViewer += OnSimChat;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.Error("[CHAT]: NewClient exception trap:" + ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
|
||||
UUID fromAgentID, string fromName, ChatTypeEnum type,
|
||||
|
|
|
@ -93,6 +93,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
|||
m_scenes.Add(scene);
|
||||
scene.EventManager.OnNewClient += OnNewClient;
|
||||
scene.EventManager.OnChatFromWorld += OnSimChat;
|
||||
scene.EventManager.OnChatFromClient += OnSimChat;
|
||||
scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
|
||||
scene.EventManager.OnMakeChildAgent += OnMakeChildAgent;
|
||||
}
|
||||
|
@ -236,7 +237,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
|||
|
||||
if (avatar != null)
|
||||
{
|
||||
fromName = avatar.Firstname + " " + avatar.Lastname;
|
||||
fromName = avatar.Name;
|
||||
}
|
||||
|
||||
// Try to reconnect to server if not connected
|
||||
|
@ -277,21 +278,19 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
|||
{
|
||||
try
|
||||
{
|
||||
string clientName = String.Format("{0} {1}", client.FirstName, client.LastName);
|
||||
|
||||
client.OnChatFromViewer += OnSimChat;
|
||||
// client.OnChatFromViewer += OnSimChat;
|
||||
client.OnLogout += OnClientLoggedOut;
|
||||
client.OnConnectionClosed += OnClientLoggedOut;
|
||||
|
||||
if (clientName != m_last_new_user)
|
||||
if (client.Name != m_last_new_user)
|
||||
{
|
||||
if ((m_irc.Enabled) && (m_irc.Connected))
|
||||
{
|
||||
m_log.DebugFormat("[IRC] {0} logging on", clientName);
|
||||
m_log.DebugFormat("[IRC] {0} logging on", client.Name);
|
||||
m_irc.PrivMsg(m_irc.Nick, "Sim",
|
||||
String.Format("notices {0} logging on", clientName));
|
||||
String.Format("notices {0} logging on", client.Name));
|
||||
}
|
||||
m_last_new_user = clientName;
|
||||
m_last_new_user = client.Name;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -343,21 +342,20 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
|||
{
|
||||
if ((m_irc.Enabled) && (m_irc.Connected))
|
||||
{
|
||||
string clientName = String.Format("{0} {1}", client.FirstName, client.LastName);
|
||||
// handles simple case. May not work for hundred connecting in per second.
|
||||
// and the NewClients calles getting interleved
|
||||
// but filters out multiple reports
|
||||
if (clientName != m_last_leaving_user)
|
||||
if (client.Name != m_last_leaving_user)
|
||||
{
|
||||
Console.WriteLine("Avatar was seen logging out.");
|
||||
//Console.ReadLine();
|
||||
Console.WriteLine();
|
||||
m_last_leaving_user = clientName;
|
||||
m_irc.PrivMsg(m_irc.Nick, "Sim", String.Format("notices {0} logging out", clientName));
|
||||
m_log.InfoFormat("[IRC]: {0} logging out", clientName);
|
||||
m_last_leaving_user = client.Name;
|
||||
m_irc.PrivMsg(m_irc.Nick, "Sim", String.Format("notices {0} logging out", client.Name));
|
||||
m_log.InfoFormat("[IRC]: {0} logging out", client.Name);
|
||||
}
|
||||
|
||||
if (m_last_new_user == clientName)
|
||||
if (m_last_new_user == client.Name)
|
||||
m_last_new_user = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
|
|||
private int _conciergeChannel = 42;
|
||||
private List<Scene> _scenes = new List<Scene>();
|
||||
private IConfig _config;
|
||||
private string _whoami = null;
|
||||
private string _whoami = "conferencier";
|
||||
|
||||
internal object _syncy = new object();
|
||||
|
||||
|
@ -78,8 +78,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
|
|||
return;
|
||||
}
|
||||
|
||||
if (_config != null)
|
||||
{
|
||||
_conciergeChannel = config.Configs["Concierge"].GetInt("concierge_channel", _conciergeChannel);
|
||||
_whoami = _config.GetString("concierge_name", "conferencier");
|
||||
_whoami = _config.GetString("whoami", "conferencier");
|
||||
}
|
||||
_log.InfoFormat("[Concierge] reporting as \"{0}\" to our users", _whoami);
|
||||
|
||||
lock (_syncy)
|
||||
{
|
||||
|
@ -88,8 +92,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
|
|||
_scenes.Add(scene);
|
||||
// subscribe to NewClient events
|
||||
scene.EventManager.OnNewClient += OnNewClient;
|
||||
scene.EventManager.OnNewClient += OnNewClient;
|
||||
|
||||
// subscribe to *Chat events
|
||||
// subscribe to *Chat events and FilterChat* events
|
||||
scene.EventManager.OnChatFromWorld += OnSimChat;
|
||||
scene.EventManager.OnChatBroadcast += OnSimBroadcast;
|
||||
|
||||
|
@ -124,18 +129,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
|
|||
#region ISimChat Members
|
||||
public void OnSimBroadcast(Object sender, OSChatMessage c)
|
||||
{
|
||||
if (_conciergeChannel == c.Channel)
|
||||
{
|
||||
// concierge request: interpret
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 == c.Channel || DEBUG_CHANNEL == c.Channel)
|
||||
{
|
||||
// log as avatar/prim chat
|
||||
return;
|
||||
}
|
||||
|
||||
// log to buffer?
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -149,6 +143,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
|
|||
|
||||
if (0 == c.Channel || DEBUG_CHANNEL == c.Channel)
|
||||
{
|
||||
// if (_amplify)
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
// log as avatar/prim chat
|
||||
return;
|
||||
}
|
||||
|
@ -161,14 +160,20 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
|
|||
|
||||
public void OnNewClient(IClientAPI client)
|
||||
{
|
||||
try
|
||||
{
|
||||
client.OnChatFromViewer += OnSimChat;
|
||||
client.OnLogout += OnClientLoggedOut;
|
||||
client.OnConnectionClosed += OnClientLoggedOut;
|
||||
|
||||
_log.DebugFormat("[Concierge] {0} logs on to {1}", client.Name, client.Scene.RegionInfo.RegionName);
|
||||
AnnounceToAgentsRegion(client, String.Format("{0} logs on to {1}", client.Name, client.Scene.RegionInfo.RegionName));
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
public void OnClientLoggedOut(IClientAPI client)
|
||||
{
|
||||
_log.Error("[Concierge]: NewClient exception trap:" + ex.ToString());
|
||||
}
|
||||
client.OnLogout -= OnClientLoggedOut;
|
||||
client.OnConnectionClosed -= OnClientLoggedOut;
|
||||
|
||||
_log.DebugFormat("[Concierge] {0} logs off from {1}", client.Name, client.Scene.RegionInfo.RegionName);
|
||||
AnnounceToAgentsRegion(client, String.Format("{0} logs off from {1}", client.Name, client.Scene.RegionInfo.RegionName));
|
||||
}
|
||||
|
||||
|
||||
|
@ -188,13 +193,22 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
|
|||
|
||||
public void ClientLoggedOut(IClientAPI client)
|
||||
{
|
||||
string clientName = String.Format("{0} {1}", client.FirstName, client.LastName);
|
||||
_log.DebugFormat("[CONCIERGE] {0} logging off.", clientName);
|
||||
_log.DebugFormat("[Concierge] {0} logs out of {1}", client.Name, client.Scene.RegionInfo.RegionName);
|
||||
AnnounceToAgentsRegion(client, String.Format("{0} logs out of {1}", client.Name, client.Scene.RegionInfo.RegionName));
|
||||
}
|
||||
|
||||
|
||||
static private Vector3 posOfGod = new Vector3(128, 128, 9999);
|
||||
|
||||
protected void AnnounceToAgentsRegion(IClientAPI client, string msg)
|
||||
{
|
||||
ScenePresence agent = null;
|
||||
if ((client.Scene is Scene) && (client.Scene as Scene).TryGetAvatar(client.AgentId, out agent))
|
||||
AnnounceToAgentsRegion(agent, msg);
|
||||
else
|
||||
_log.DebugFormat("[Concierge] could not find an agent for client {0}", client.Name);
|
||||
}
|
||||
|
||||
protected void AnnounceToAgentsRegion(ScenePresence scenePresence, string msg)
|
||||
{
|
||||
OSChatMessage c = new OSChatMessage();
|
||||
|
|
|
@ -381,7 +381,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
|
|||
protected void StartManaging(IClientAPI client)
|
||||
{
|
||||
m_log.Debug("[CONTENT MANAGEMENT] Registering channel with chat services.");
|
||||
client.OnChatFromViewer += SimChatSent;
|
||||
// client.OnChatFromClient += SimChatSent;
|
||||
//init = true;
|
||||
|
||||
OnNewClient(client);
|
||||
|
@ -412,7 +412,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
|
|||
{
|
||||
IClientAPI client = presence.ControllingClient;
|
||||
m_log.Debug("[CONTENT MANAGEMENT] Unregistering channel with chat services.");
|
||||
client.OnChatFromViewer -= SimChatSent;
|
||||
// client.OnChatFromViewer -= SimChatSent;
|
||||
|
||||
m_log.Debug("[CONTENT MANAGEMENT] Removing handlers to client");
|
||||
client.OnUpdatePrimScale -= UpdateSingleScale;
|
||||
|
@ -641,6 +641,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
|
|||
m_log.Debug("[CONTENT MANAGEMENT] Initializing Content Management System.");
|
||||
|
||||
scene.EventManager.OnNewClient += StartManaging;
|
||||
scene.EventManager.OnChatFromClient += SimChatSent;
|
||||
scene.EventManager.OnRemovePresence += StopManaging;
|
||||
// scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
|
||||
scene.EventManager.OnObjectBeingRemovedFromScene += GroupBeingDeleted;
|
||||
|
|
|
@ -116,7 +116,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
|
|||
m_scene = scene;
|
||||
m_scene.RegisterModuleInterface<IWorldComm>(this);
|
||||
m_listenerManager = new ListenerManager(maxlisteners, maxhandles);
|
||||
m_scene.EventManager.OnNewClient += NewClient;
|
||||
m_scene.EventManager.OnChatFromClient += DeliverClientMessage;
|
||||
m_pendingQ = new Queue();
|
||||
m_pending = Queue.Synchronized(m_pendingQ);
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
|
|||
/// enqueue the message for delivery to the objects listen event handler.
|
||||
/// The enqueued ListenerInfo no longer has filter values, but the actually trigged values.
|
||||
/// Objects that do an llSay have their messages delivered here and for nearby avatars,
|
||||
/// the OnChatFromViewer event is used.
|
||||
/// the OnChatFromClient event is used.
|
||||
/// </summary>
|
||||
/// <param name="type">type of delvery (whisper,say,shout or regionwide)</param>
|
||||
/// <param name="channel">channel to sent on</param>
|
||||
|
@ -311,10 +311,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
|
|||
|
||||
#endregion
|
||||
|
||||
private void NewClient(IClientAPI client)
|
||||
{
|
||||
client.OnChatFromViewer += DeliverClientMessage;
|
||||
}
|
||||
// private void NewClient(IClientAPI client)
|
||||
// {
|
||||
// client.OnChatFromViewer += DeliverClientMessage;
|
||||
// }
|
||||
|
||||
/********************************************************************
|
||||
*
|
||||
|
|
|
@ -59,22 +59,22 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
|
|||
|
||||
public void Say(string message)
|
||||
{
|
||||
SendOnChatFromViewer(message, ChatTypeEnum.Say);
|
||||
SendOnChatFromClient(message, ChatTypeEnum.Say);
|
||||
}
|
||||
|
||||
public void Shout(string message)
|
||||
{
|
||||
SendOnChatFromViewer(message, ChatTypeEnum.Shout);
|
||||
SendOnChatFromClient(message, ChatTypeEnum.Shout);
|
||||
}
|
||||
|
||||
public void Whisper(string message)
|
||||
{
|
||||
SendOnChatFromViewer(message, ChatTypeEnum.Whisper);
|
||||
SendOnChatFromClient(message, ChatTypeEnum.Whisper);
|
||||
}
|
||||
|
||||
public void Broadcast(string message)
|
||||
{
|
||||
SendOnChatFromViewer(message, ChatTypeEnum.Broadcast);
|
||||
SendOnChatFromClient(message, ChatTypeEnum.Broadcast);
|
||||
}
|
||||
|
||||
public void GiveMoney(UUID target, int amount)
|
||||
|
@ -132,19 +132,19 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
|
|||
|
||||
#region Internal Functions
|
||||
|
||||
private void SendOnChatFromViewer(string message, ChatTypeEnum chatType)
|
||||
private void SendOnChatFromClient(string message, ChatTypeEnum chatType)
|
||||
{
|
||||
OSChatMessage chatFromViewer = new OSChatMessage();
|
||||
chatFromViewer.Channel = 0;
|
||||
chatFromViewer.From = Name;
|
||||
chatFromViewer.Message = message;
|
||||
chatFromViewer.Position = StartPos;
|
||||
chatFromViewer.Scene = m_scene;
|
||||
chatFromViewer.Sender = this;
|
||||
chatFromViewer.SenderUUID = AgentId;
|
||||
chatFromViewer.Type = chatType;
|
||||
OSChatMessage chatFromClient = new OSChatMessage();
|
||||
chatFromClient.Channel = 0;
|
||||
chatFromClient.From = Name;
|
||||
chatFromClient.Message = message;
|
||||
chatFromClient.Position = StartPos;
|
||||
chatFromClient.Scene = m_scene;
|
||||
chatFromClient.Sender = this;
|
||||
chatFromClient.SenderUUID = AgentId;
|
||||
chatFromClient.Type = chatType;
|
||||
|
||||
OnChatFromViewer(this, chatFromViewer);
|
||||
OnChatFromClient(this, chatFromClient);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -161,7 +161,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
|
|||
public event Action<IClientAPI> OnConnectionClosed;
|
||||
public event GenericMessage OnGenericMessage;
|
||||
public event ImprovedInstantMessage OnInstantMessage;
|
||||
public event ChatMessage OnChatFromViewer;
|
||||
public event ChatMessage OnChatFromClient;
|
||||
public event TextureRequest OnRequestTexture;
|
||||
public event RezObject OnRezObject;
|
||||
public event ModifyTerrain OnModifyTerrain;
|
||||
|
|
|
@ -230,14 +230,20 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
public event DeregisterCapsEvent OnDeregisterCaps;
|
||||
/// <summary>
|
||||
/// ChatFromWorldEvent is called via Scene when a chat message
|
||||
/// from world comes in (chat from viewer is available via
|
||||
/// client.OnChatFromViewer).
|
||||
/// from world comes in.
|
||||
/// </summary>
|
||||
public delegate void ChatFromWorldEvent(Object sender, OSChatMessage chat);
|
||||
public event ChatFromWorldEvent OnChatFromWorld;
|
||||
/// <summary>
|
||||
/// ChatFromClientEvent is triggered via ChatModule (or
|
||||
/// substitutes thereof) when a chat message
|
||||
/// from the client comes in.
|
||||
/// </summary>
|
||||
public delegate void ChatFromClientEvent(Object sender, OSChatMessage chat);
|
||||
public event ChatFromClientEvent OnChatFromClient;
|
||||
/// <summary>
|
||||
/// ChatBroadcastEvent is called via Scene when a broadcast chat message
|
||||
/// from world comes in (chat from viewer is available via client.OnChatFromViewer).
|
||||
/// from world comes in
|
||||
/// </summary>
|
||||
public delegate void ChatBroadcastEvent(Object sender, OSChatMessage chat);
|
||||
public event ChatBroadcastEvent OnChatBroadcast;
|
||||
|
@ -349,6 +355,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps;
|
||||
private DeregisterCapsEvent handlerDeregisterCaps = null; // OnDeregisterCaps;
|
||||
private ChatFromWorldEvent handlerChatFromWorld = null; // OnChatFromWorld;
|
||||
private ChatFromClientEvent handlerChatFromClient = null; // OnChatFromClient;
|
||||
private ChatBroadcastEvent handlerChatBroadcast = null; // OnChatBroadcast;
|
||||
private NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete = null;
|
||||
private RequestChangeWaterHeight handlerRequestChangeWaterHeight = null; //OnRequestChangeWaterHeight
|
||||
|
@ -772,6 +779,15 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public void TriggerOnChatFromClient(Object sender, OSChatMessage chat)
|
||||
{
|
||||
handlerChatFromClient = OnChatFromClient;
|
||||
if (handlerChatFromClient != null)
|
||||
{
|
||||
handlerChatFromClient(sender, chat);
|
||||
}
|
||||
}
|
||||
|
||||
public void TriggerOnChatBroadcast(Object sender, OSChatMessage chat)
|
||||
{
|
||||
handlerChatBroadcast = OnChatBroadcast;
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace OpenSim.Region.Examples.SimpleModule
|
|||
public event Action<IClientAPI> OnConnectionClosed;
|
||||
|
||||
public event ImprovedInstantMessage OnInstantMessage;
|
||||
public event ChatMessage OnChatFromViewer;
|
||||
public event ChatMessage OnChatFromClient;
|
||||
public event TextureRequest OnRequestTexture;
|
||||
public event RezObject OnRezObject;
|
||||
public event ModifyTerrain OnModifyTerrain;
|
||||
|
@ -696,7 +696,7 @@ namespace OpenSim.Region.Examples.SimpleModule
|
|||
|
||||
if (count >= 10)
|
||||
{
|
||||
if (OnChatFromViewer != null)
|
||||
if (OnChatFromClient != null)
|
||||
{
|
||||
OSChatMessage args = new OSChatMessage();
|
||||
args.Message = "Hey You! Get out of my Home. This is my Region";
|
||||
|
@ -706,7 +706,7 @@ namespace OpenSim.Region.Examples.SimpleModule
|
|||
args.Sender = this;
|
||||
args.Type = ChatTypeEnum.Shout;
|
||||
|
||||
OnChatFromViewer(this, args);
|
||||
OnChatFromClient(this, args);
|
||||
}
|
||||
count = -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue