* Clearing up confusion with Agent.Avatar by making it a SimulationObject that is passed in through the constructor. This should prevent duplicate notions of an avatar in the scene * Fixed the "you don't own this object" issue after moving a prim. The fix is rather hacky and will be replaced when we stop sending full object updates for every change git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@2465 52acb1d6-8a22-11de-b505-999d5b087335
73 lines
3.0 KiB
C#
73 lines
3.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using ExtensionLoader;
|
|
using OpenMetaverse;
|
|
using OpenMetaverse.Packets;
|
|
|
|
namespace Simian.Extensions
|
|
{
|
|
public class Messaging : IExtension<Simian>
|
|
{
|
|
Simian server;
|
|
|
|
public Messaging()
|
|
{
|
|
}
|
|
|
|
public void Start(Simian server)
|
|
{
|
|
this.server = server;
|
|
|
|
server.UDP.RegisterPacketCallback(PacketType.ChatFromViewer, new PacketCallback(ChatFromViewerHandler));
|
|
server.UDP.RegisterPacketCallback(PacketType.ImprovedInstantMessage, new PacketCallback(ImprovedInstantMessageHandler));
|
|
}
|
|
|
|
public void Stop()
|
|
{
|
|
}
|
|
|
|
void ChatFromViewerHandler(Packet packet, Agent agent)
|
|
{
|
|
ChatFromViewerPacket viewerChat = (ChatFromViewerPacket)packet;
|
|
|
|
server.Scene.ObjectChat(this, agent.ID, agent.ID, ChatAudibleLevel.Fully, (ChatType)viewerChat.ChatData.Type,
|
|
ChatSourceType.Agent, agent.FullName, agent.Avatar.GetSimulatorPosition(), viewerChat.ChatData.Channel,
|
|
Utils.BytesToString(viewerChat.ChatData.Message));
|
|
}
|
|
|
|
void ImprovedInstantMessageHandler(Packet packet, Agent agent)
|
|
{
|
|
ImprovedInstantMessagePacket im = (ImprovedInstantMessagePacket)packet;
|
|
InstantMessageDialog dialog = (InstantMessageDialog)im.MessageBlock.Dialog;
|
|
|
|
if (dialog == InstantMessageDialog.MessageFromAgent)
|
|
{
|
|
// HACK: Only works for agents currently online
|
|
Agent recipient;
|
|
if (server.Scene.TryGetAgent(im.MessageBlock.ToAgentID, out recipient))
|
|
{
|
|
// FIXME: Look into the fields we are setting to default values
|
|
ImprovedInstantMessagePacket sendIM = new ImprovedInstantMessagePacket();
|
|
sendIM.MessageBlock.RegionID = server.Scene.RegionID;
|
|
sendIM.MessageBlock.ParentEstateID = 1;
|
|
sendIM.MessageBlock.FromGroup = false;
|
|
sendIM.MessageBlock.FromAgentName = Utils.StringToBytes(agent.FullName);
|
|
sendIM.MessageBlock.ToAgentID = im.MessageBlock.ToAgentID;
|
|
sendIM.MessageBlock.Dialog = im.MessageBlock.Dialog;
|
|
sendIM.MessageBlock.Offline = (byte)InstantMessageOnline.Online;
|
|
sendIM.MessageBlock.ID = agent.ID;
|
|
sendIM.MessageBlock.Message = im.MessageBlock.Message;
|
|
sendIM.MessageBlock.BinaryBucket = new byte[0];
|
|
sendIM.MessageBlock.Timestamp = Utils.DateTimeToUnixTime(DateTime.Now);
|
|
sendIM.MessageBlock.Position = agent.Avatar.GetSimulatorPosition();
|
|
|
|
sendIM.AgentData.AgentID = agent.ID;
|
|
|
|
server.UDP.SendPacket(recipient.ID, sendIM, PacketCategory.Messaging);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|