Added Packet handlers to SimClient
parent
af93263a3b
commit
548b125b7c
|
@ -50,6 +50,7 @@ using OpenSim.Servers;
|
|||
|
||||
namespace OpenSim
|
||||
{
|
||||
|
||||
public class OpenSimMain : OpenSimNetworkHandler, conscmd_callback
|
||||
{
|
||||
private PhysicsManager physManager;
|
||||
|
|
|
@ -43,6 +43,8 @@ using OpenSim.Assets;
|
|||
|
||||
namespace OpenSim
|
||||
{
|
||||
public delegate bool PacketMethod(SimClient simClient, Packet packet);
|
||||
|
||||
/// <summary>
|
||||
/// Handles new client connections
|
||||
/// Constructor takes a single Packet and authenticates everything
|
||||
|
@ -80,6 +82,12 @@ namespace OpenSim
|
|||
private bool m_sandboxMode;
|
||||
private int cachedtextureserial = 0;
|
||||
|
||||
// local packet handler list not currently used but is here so each client could have a different handler for a packet to another client
|
||||
// this is so we could do such things as have multiple world objects in a sim (or multiple "sims" handled by one server and different clients in different worlds
|
||||
// maybe not a very practicle example but there are various other things it could be used for.
|
||||
// protected Dictionary<string, PacketMethod> m_packetHandlers = new Dictionary<string, PacketMethod>();
|
||||
|
||||
protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>();
|
||||
|
||||
public IUserServer UserServer
|
||||
{
|
||||
|
@ -89,6 +97,37 @@ namespace OpenSim
|
|||
}
|
||||
}
|
||||
|
||||
public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
|
||||
{
|
||||
bool result = false;
|
||||
lock (PacketHandlers)
|
||||
{
|
||||
if (!PacketHandlers.ContainsKey(packetType))
|
||||
{
|
||||
PacketHandlers.Add(packetType, handler);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected virtual bool ProcessPacketMethod(Packet packet)
|
||||
{
|
||||
bool result = false;
|
||||
bool found = false;
|
||||
PacketMethod method;
|
||||
lock (PacketHandlers)
|
||||
{
|
||||
found = PacketHandlers.TryGetValue(packet.Type, out method);
|
||||
}
|
||||
if (found)
|
||||
{
|
||||
result = method(this, packet);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void ack_pack(Packet Pack)
|
||||
{
|
||||
//libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket();
|
||||
|
@ -112,7 +151,6 @@ namespace OpenSim
|
|||
protected virtual void ProcessInPacket(Packet Pack)
|
||||
{
|
||||
ack_pack(Pack);
|
||||
System.Text.Encoding _enc = System.Text.Encoding.ASCII;
|
||||
if (debug)
|
||||
{
|
||||
if (Pack.Type != PacketType.AgentUpdate)
|
||||
|
@ -120,6 +158,15 @@ namespace OpenSim
|
|||
Console.WriteLine(Pack.Type.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
if (this.ProcessPacketMethod(Pack))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Text.Encoding _enc = System.Text.Encoding.ASCII;
|
||||
|
||||
switch (Pack.Type)
|
||||
{
|
||||
case PacketType.CompleteAgentMovement:
|
||||
|
@ -438,16 +485,16 @@ namespace OpenSim
|
|||
case 1:
|
||||
if (modify.ParcelData.Length > 0)
|
||||
{
|
||||
int mody = (int) modify.ParcelData[0].North;
|
||||
int modx = (int) modify.ParcelData[0].West;
|
||||
int mody = (int)modify.ParcelData[0].North;
|
||||
int modx = (int)modify.ParcelData[0].West;
|
||||
// Console.WriteLine("height in packet is " + modify.ModifyBlock.Height.ToString());
|
||||
// Console.WriteLine("current height at that point is " + this.m_world.LandMap[(mody * 256) + modx].ToString());
|
||||
|
||||
this.m_world.LandMap[(mody * 256) + modx -1 ] += 0.05f;
|
||||
this.m_world.LandMap[(mody * 256) + modx - 1] += 0.05f;
|
||||
this.m_world.LandMap[(mody * 256) + modx] += 0.1f;
|
||||
this.m_world.LandMap[(mody * 256) + modx + 1] += 0.05f;
|
||||
this.m_world.LandMap[((mody+1) * 256) + modx] += 0.05f;
|
||||
this.m_world.LandMap[((mody -1) * 256) + modx] += 0.05f;
|
||||
this.m_world.LandMap[((mody + 1) * 256) + modx] += 0.05f;
|
||||
this.m_world.LandMap[((mody - 1) * 256) + modx] += 0.05f;
|
||||
m_world.RegenerateTerrain(true, modx, mody);
|
||||
}
|
||||
break;
|
||||
|
@ -526,6 +573,7 @@ namespace OpenSim
|
|||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ResendUnacked()
|
||||
{
|
||||
|
@ -744,7 +792,7 @@ namespace OpenSim
|
|||
userEP = remoteEP;
|
||||
PacketQueue = new BlockingQueue<QueItem>();
|
||||
|
||||
this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache );
|
||||
this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);
|
||||
AckTimer = new System.Timers.Timer(500);
|
||||
AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
|
||||
AckTimer.Start();
|
||||
|
|
Loading…
Reference in New Issue