OSChatMessage coming from client.0.6.0-stable
parent
fd108872d8
commit
4218744a26
|
@ -114,55 +114,43 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||||
client.OnChatFromClient += OnChatFromClient;
|
client.OnChatFromClient += OnChatFromClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnChatFromClient(Object sender, OSChatMessage e)
|
protected OSChatMessage FixPositionOfChatMessage(OSChatMessage c)
|
||||||
{
|
{
|
||||||
|
ScenePresence avatar;
|
||||||
|
Scene scene = (Scene)c.Scene;
|
||||||
|
if ((avatar = scene.GetScenePresence(c.Sender.AgentId)) != null)
|
||||||
|
c.Position = avatar.AbsolutePosition;
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnChatFromClient(Object sender, OSChatMessage c)
|
||||||
|
{
|
||||||
|
c = FixPositionOfChatMessage(c);
|
||||||
|
|
||||||
// redistribute to interested subscribers
|
// redistribute to interested subscribers
|
||||||
Scene scene = (Scene)e.Scene;
|
Scene scene = (Scene)c.Scene;
|
||||||
scene.EventManager.TriggerOnChatFromClient(sender, e);
|
scene.EventManager.TriggerOnChatFromClient(sender, c);
|
||||||
|
|
||||||
// early return if not on public or debug channel
|
// early return if not on public or debug channel
|
||||||
if (e.Channel != 0 && e.Channel != DEBUG_CHANNEL) return;
|
if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return;
|
||||||
|
|
||||||
// sanity check:
|
// sanity check:
|
||||||
if (e.Sender == null)
|
if (c.Sender == null)
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat("[CHAT] OnChatFromClient from {0} has empty Sender field!", sender);
|
m_log.ErrorFormat("[CHAT] OnChatFromClient from {0} has empty Sender field!", sender);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// string message = e.Message;
|
DeliverChatToAvatars(ChatSourceType.Agent, c);
|
||||||
// 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);
|
|
||||||
DeliverChatToAvatars(ChatSourceType.Agent, e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnChatFromWorld(Object sender, OSChatMessage e)
|
public virtual void OnChatFromWorld(Object sender, OSChatMessage c)
|
||||||
{
|
{
|
||||||
// early return if not on public or debug channel
|
// early return if not on public or debug channel
|
||||||
if (e.Channel != 0 && e.Channel != DEBUG_CHANNEL) return;
|
if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return;
|
||||||
|
|
||||||
// // Filled in since it's easier than rewriting right now.
|
DeliverChatToAvatars(ChatSourceType.Object, c);
|
||||||
// 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);
|
|
||||||
DeliverChatToAvatars(ChatSourceType.Object, e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
|
protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
|
||||||
|
@ -188,7 +176,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||||
}
|
}
|
||||||
ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
|
ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
|
||||||
fromPos = avatar.AbsolutePosition;
|
fromPos = avatar.AbsolutePosition;
|
||||||
fromName = avatar.Firstname + " " + avatar.Lastname;
|
fromName = avatar.Name;
|
||||||
fromID = c.Sender.AgentId;
|
fromID = c.Sender.AgentId;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -203,6 +191,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||||
if (message.Length >= 1000) // libomv limit
|
if (message.Length >= 1000) // libomv limit
|
||||||
message = message.Substring(0, 1000);
|
message = message.Substring(0, 1000);
|
||||||
|
|
||||||
|
// m_log.DebugFormat("[CHAT] DCTA: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, c.Type, sourceType);
|
||||||
|
|
||||||
foreach (Scene s in m_scenes)
|
foreach (Scene s in m_scenes)
|
||||||
{
|
{
|
||||||
s.ForEachScenePresence(delegate(ScenePresence presence)
|
s.ForEachScenePresence(delegate(ScenePresence presence)
|
||||||
|
@ -213,24 +203,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected virtual 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);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
static private Vector3 CenterOfRegion = new Vector3(128, 128, 30);
|
||||||
public virtual void OnChatBroadcast(Object sender, OSChatMessage c)
|
public virtual void OnChatBroadcast(Object sender, OSChatMessage c)
|
||||||
{
|
{
|
||||||
// unless the chat to be broadcast is of type Region, we
|
// unless the chat to be broadcast is of type Region, we
|
||||||
|
@ -249,16 +223,20 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||||
|
|
||||||
// broadcast chat works by redistributing every incoming chat
|
// broadcast chat works by redistributing every incoming chat
|
||||||
// message to each avatar in the scene.
|
// message to each avatar in the scene.
|
||||||
Vector3 pos = new Vector3(128, 128, 30);
|
string fromName = c.From;
|
||||||
|
|
||||||
UUID fromID = UUID.Zero;
|
UUID fromID = UUID.Zero;
|
||||||
ChatSourceType sourceType = ChatSourceType.Object;
|
ChatSourceType sourceType = ChatSourceType.Object;
|
||||||
if (null != c.Sender)
|
if (null != c.Sender)
|
||||||
{
|
{
|
||||||
|
ScenePresence avatar = (c.Scene as Scene).GetScenePresence(c.Sender.AgentId);
|
||||||
fromID = c.Sender.AgentId;
|
fromID = c.Sender.AgentId;
|
||||||
|
fromName = avatar.Name;
|
||||||
sourceType = ChatSourceType.Agent;
|
sourceType = ChatSourceType.Agent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
|
||||||
|
|
||||||
((Scene)c.Scene).ForEachScenePresence(
|
((Scene)c.Scene).ForEachScenePresence(
|
||||||
delegate(ScenePresence presence)
|
delegate(ScenePresence presence)
|
||||||
{
|
{
|
||||||
|
@ -274,7 +252,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||||
(((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
|
(((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
client.SendChatMessage(c.Message, (byte)cType, pos, c.From, fromID,
|
client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID,
|
||||||
(byte)sourceType, (byte)ChatAudibleLevel.Fully);
|
(byte)sourceType, (byte)ChatAudibleLevel.Fully);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@ using OpenSim.Framework;
|
||||||
using OpenSim.Region.Environment.Interfaces;
|
using OpenSim.Region.Environment.Interfaces;
|
||||||
using OpenSim.Region.Environment.Scenes;
|
using OpenSim.Region.Environment.Scenes;
|
||||||
|
|
||||||
using log4net;
|
// using log4net;
|
||||||
using System.Reflection;
|
// using System.Reflection;
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
|
@ -336,9 +336,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
|
||||||
private void DeliverClientMessage(Object sender, OSChatMessage e)
|
private void DeliverClientMessage(Object sender, OSChatMessage e)
|
||||||
{
|
{
|
||||||
if (null != e.Sender)
|
if (null != e.Sender)
|
||||||
DeliverMessage(e.Type, e.Channel, e.Sender.Name, e.Sender.AgentId, e.Message); // , e.Position);
|
DeliverMessage(e.Type, e.Channel, e.Sender.Name, e.Sender.AgentId, e.Message, e.Position);
|
||||||
else
|
else
|
||||||
DeliverMessage(e.Type, e.Channel, e.From, UUID.Zero, e.Message); // , e.Position);
|
DeliverMessage(e.Type, e.Channel, e.From, UUID.Zero, e.Message, e.Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] GetSerializationData(UUID itemID)
|
public Object[] GetSerializationData(UUID itemID)
|
||||||
|
|
Loading…
Reference in New Issue