* Move a few of the ProcessInPacket switch case blocks into packet handler delegates

0.6.8-post-fixes
Teravus Ovares (Dan Olivares) 2009-11-21 21:58:11 -05:00
parent f7916d10f3
commit 079691b98f
1 changed files with 103 additions and 6 deletions

View File

@ -350,7 +350,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected IAssetService m_assetService;
private IHyperAssetService m_hyperAssets;
private const bool m_checkPackets = true;
#endregion Class Members
@ -4297,6 +4297,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest);
AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest);
AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage);
AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest);
AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate);
AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
}
#region Packet Handlers
@ -4512,6 +4517,98 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return true;
}
private bool HandleAvatarPropertiesRequest(IClientAPI sender, Packet Pack)
{
AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
#region Packet Session and User Check
if (m_checkPackets)
{
if (avatarProperties.AgentData.SessionID != SessionId ||
avatarProperties.AgentData.AgentID != AgentId)
return true;
}
#endregion
RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties;
if (handlerRequestAvatarProperties != null)
{
handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID);
}
return true;
}
private bool HandleChatFromViewer(IClientAPI sender, Packet Pack)
{
ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
#region Packet Session and User Check
if (m_checkPackets)
{
if (inchatpack.AgentData.SessionID != SessionId ||
inchatpack.AgentData.AgentID != AgentId)
return true;
}
#endregion
string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
byte[] message = inchatpack.ChatData.Message;
byte type = inchatpack.ChatData.Type;
Vector3 fromPos = new Vector3(); // ClientAvatar.Pos;
// UUID fromAgentID = AgentId;
int channel = inchatpack.ChatData.Channel;
if (OnChatFromClient != null)
{
OSChatMessage args = new OSChatMessage();
args.Channel = channel;
args.From = fromName;
args.Message = Utils.BytesToString(message);
args.Type = (ChatTypeEnum)type;
args.Position = fromPos;
args.Scene = Scene;
args.Sender = this;
args.SenderUUID = this.AgentId;
ChatMessage handlerChatFromClient = OnChatFromClient;
if (handlerChatFromClient != null)
handlerChatFromClient(this, args);
}
return true;
}
private bool HandlerAvatarPropertiesUpdate(IClientAPI sender, Packet Pack)
{
AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack;
#region Packet Session and User Check
if (m_checkPackets)
{
if (avatarProps.AgentData.SessionID != SessionId ||
avatarProps.AgentData.AgentID != AgentId)
return true;
}
#endregion
UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties;
if (handlerUpdateAvatarProperties != null)
{
AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData;
UserProfileData UserProfile = new UserProfileData();
UserProfile.ID = AgentId;
UserProfile.AboutText = Utils.BytesToString(Properties.AboutText);
UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
UserProfile.FirstLifeImage = Properties.FLImageID;
UserProfile.Image = Properties.ImageID;
UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
handlerUpdateAvatarProperties(this, UserProfile);
}
return true;
}
#endregion Packet Handlers
public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
@ -5003,13 +5100,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return;
}
const bool m_checkPackets = true;
// Main packet processing conditional
switch (Pack.Type)
{
#region Scene/Avatar
/*
case PacketType.AvatarPropertiesRequest:
AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
@ -5029,7 +5126,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
break;
case PacketType.ChatFromViewer:
ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
@ -5068,7 +5165,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
handlerChatFromClient(this, args);
}
break;
case PacketType.AvatarPropertiesUpdate:
AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack;
@ -5096,7 +5193,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
handlerUpdateAvatarProperties(this, UserProfile);
}
break;
*/
case PacketType.ScriptDialogReply:
ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;