Added Packet handlers to SimClient
parent
af93263a3b
commit
548b125b7c
|
@ -50,6 +50,7 @@ using OpenSim.Servers;
|
||||||
|
|
||||||
namespace OpenSim
|
namespace OpenSim
|
||||||
{
|
{
|
||||||
|
|
||||||
public class OpenSimMain : OpenSimNetworkHandler, conscmd_callback
|
public class OpenSimMain : OpenSimNetworkHandler, conscmd_callback
|
||||||
{
|
{
|
||||||
private PhysicsManager physManager;
|
private PhysicsManager physManager;
|
||||||
|
|
|
@ -43,6 +43,8 @@ using OpenSim.Assets;
|
||||||
|
|
||||||
namespace OpenSim
|
namespace OpenSim
|
||||||
{
|
{
|
||||||
|
public delegate bool PacketMethod(SimClient simClient, Packet packet);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles new client connections
|
/// Handles new client connections
|
||||||
/// Constructor takes a single Packet and authenticates everything
|
/// Constructor takes a single Packet and authenticates everything
|
||||||
|
@ -80,6 +82,12 @@ namespace OpenSim
|
||||||
private bool m_sandboxMode;
|
private bool m_sandboxMode;
|
||||||
private int cachedtextureserial = 0;
|
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
|
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)
|
private void ack_pack(Packet Pack)
|
||||||
{
|
{
|
||||||
//libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket();
|
//libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket();
|
||||||
|
@ -112,7 +151,6 @@ namespace OpenSim
|
||||||
protected virtual void ProcessInPacket(Packet Pack)
|
protected virtual void ProcessInPacket(Packet Pack)
|
||||||
{
|
{
|
||||||
ack_pack(Pack);
|
ack_pack(Pack);
|
||||||
System.Text.Encoding _enc = System.Text.Encoding.ASCII;
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
if (Pack.Type != PacketType.AgentUpdate)
|
if (Pack.Type != PacketType.AgentUpdate)
|
||||||
|
@ -120,6 +158,15 @@ namespace OpenSim
|
||||||
Console.WriteLine(Pack.Type.ToString());
|
Console.WriteLine(Pack.Type.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.ProcessPacketMethod(Pack))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.Text.Encoding _enc = System.Text.Encoding.ASCII;
|
||||||
|
|
||||||
switch (Pack.Type)
|
switch (Pack.Type)
|
||||||
{
|
{
|
||||||
case PacketType.CompleteAgentMovement:
|
case PacketType.CompleteAgentMovement:
|
||||||
|
@ -526,6 +573,7 @@ namespace OpenSim
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ResendUnacked()
|
private void ResendUnacked()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue