* Introduced ClientManager for great justice.
parent
4699efd6cb
commit
08a1fa3f96
|
@ -0,0 +1,31 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using OpenSim.Framework.Interfaces;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework
|
||||||
|
{
|
||||||
|
public delegate void ForEachClientDelegate( IClientAPI client );
|
||||||
|
public class ClientManager
|
||||||
|
{
|
||||||
|
private Dictionary<uint, IClientAPI> m_clientThreads;
|
||||||
|
|
||||||
|
public void ForEachClient(ForEachClientDelegate whatToDo)
|
||||||
|
{
|
||||||
|
foreach (IClientAPI client in m_clientThreads.Values)
|
||||||
|
{
|
||||||
|
whatToDo(client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientManager()
|
||||||
|
{
|
||||||
|
m_clientThreads = new Dictionary<uint, IClientAPI>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(uint id, IClientAPI client )
|
||||||
|
{
|
||||||
|
m_clientThreads.Add( id, client );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -41,7 +41,7 @@ namespace OpenSim.Region.ClientStack
|
||||||
private ClientStackNetworkHandler _networkHandler;
|
private ClientStackNetworkHandler _networkHandler;
|
||||||
private IWorld _localWorld;
|
private IWorld _localWorld;
|
||||||
public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>();
|
public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>();
|
||||||
public Dictionary<uint, IClientAPI> ClientAPIs = new Dictionary<uint, IClientAPI>();
|
public ClientManager ClientAPIs = new ClientManager();
|
||||||
|
|
||||||
public PacketServer(ClientStackNetworkHandler networkHandler)
|
public PacketServer(ClientStackNetworkHandler networkHandler)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
internal PrimData primData;
|
internal PrimData primData;
|
||||||
private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
|
private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
|
||||||
// private Dictionary<uint, IClientAPI> m_clientThreads;
|
// private ClientManager m_clientThreads;
|
||||||
private ulong m_regionHandle;
|
private ulong m_regionHandle;
|
||||||
private const uint FULL_MASK_PERMISSIONS = 2147483647;
|
private const uint FULL_MASK_PERMISSIONS = 2147483647;
|
||||||
private bool physicsEnabled = false;
|
private bool physicsEnabled = false;
|
||||||
|
|
|
@ -139,48 +139,50 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
// Console.WriteLine("Chat message");
|
// Console.WriteLine("Chat message");
|
||||||
ScenePresence avatar = null;
|
ScenePresence avatar = null;
|
||||||
foreach (IClientAPI client in m_clientThreads.Values)
|
|
||||||
{
|
|
||||||
int dis = -1000;
|
|
||||||
if (this.Avatars.ContainsKey(client.AgentId))
|
|
||||||
{
|
|
||||||
|
|
||||||
avatar = this.Avatars[client.AgentId];
|
m_clientThreads.ForEachClient(delegate(IClientAPI client)
|
||||||
// int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
|
{
|
||||||
dis= (int)avatar.Pos.GetDistanceTo(fromPos);
|
int dis = -1000;
|
||||||
//Console.WriteLine("found avatar at " +dis);
|
if (this.Avatars.ContainsKey(client.AgentId))
|
||||||
|
{
|
||||||
|
avatar = this.Avatars[client.AgentId];
|
||||||
|
// int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
|
||||||
|
dis = (int) avatar.Pos.GetDistanceTo(fromPos);
|
||||||
|
//Console.WriteLine("found avatar at " +dis);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
switch (type)
|
||||||
|
{
|
||||||
|
case 0: // Whisper
|
||||||
|
if ((dis < 10) && (dis > -10))
|
||||||
|
{
|
||||||
|
//should change so the message is sent through the avatar rather than direct to the ClientView
|
||||||
|
client.SendChatMessage(message, type, fromPos, fromName,
|
||||||
|
fromAgentID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1: // Say
|
||||||
|
if ((dis < 30) && (dis > -30))
|
||||||
|
{
|
||||||
|
Console.WriteLine("sending chat");
|
||||||
|
client.SendChatMessage(message, type, fromPos, fromName,
|
||||||
|
fromAgentID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2: // Shout
|
||||||
|
if ((dis < 100) && (dis > -100))
|
||||||
|
{
|
||||||
|
client.SendChatMessage(message, type, fromPos, fromName,
|
||||||
|
fromAgentID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
switch (type)
|
case 0xff: // Broadcast
|
||||||
{
|
client.SendChatMessage(message, type, fromPos, fromName,
|
||||||
case 0: // Whisper
|
fromAgentID);
|
||||||
if ((dis < 10) && (dis > -10))
|
break;
|
||||||
{
|
}
|
||||||
//should change so the message is sent through the avatar rather than direct to the ClientView
|
});
|
||||||
client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1: // Say
|
|
||||||
if ((dis < 30) && (dis > -30))
|
|
||||||
{
|
|
||||||
Console.WriteLine("sending chat");
|
|
||||||
client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2: // Shout
|
|
||||||
if ((dis < 100) && (dis > -100))
|
|
||||||
{
|
|
||||||
client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0xff: // Broadcast
|
|
||||||
client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -98,7 +98,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// <param name="clientThreads">Dictionary to contain client threads</param>
|
/// <param name="clientThreads">Dictionary to contain client threads</param>
|
||||||
/// <param name="regionHandle">Region Handle for this region</param>
|
/// <param name="regionHandle">Region Handle for this region</param>
|
||||||
/// <param name="regionName">Region Name for this region</param>
|
/// <param name="regionName">Region Name for this region</param>
|
||||||
public Scene(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer)
|
public Scene(ClientManager clientThreads, RegionInfo regInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer)
|
||||||
{
|
{
|
||||||
updateLock = new Mutex(false);
|
updateLock = new Mutex(false);
|
||||||
this.authenticateHandler = authen;
|
this.authenticateHandler = authen;
|
||||||
|
@ -229,10 +229,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
this.localStorage.SaveMap(this.Terrain.getHeights1D());
|
this.localStorage.SaveMap(this.Terrain.getHeights1D());
|
||||||
|
|
||||||
foreach (IClientAPI client in m_clientThreads.Values)
|
m_clientThreads.ForEachClient(delegate(IClientAPI client)
|
||||||
{
|
{
|
||||||
this.SendLayerData(client);
|
this.SendLayerData(client);
|
||||||
}
|
});
|
||||||
|
|
||||||
foreach (LLUUID UUID in Entities.Keys)
|
foreach (LLUUID UUID in Entities.Keys)
|
||||||
{
|
{
|
||||||
|
@ -260,10 +260,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
this.localStorage.SaveMap(this.Terrain.getHeights1D());
|
this.localStorage.SaveMap(this.Terrain.getHeights1D());
|
||||||
|
|
||||||
foreach (IClientAPI client in m_clientThreads.Values)
|
m_clientThreads.ForEachClient(delegate(IClientAPI client)
|
||||||
{
|
{
|
||||||
this.SendLayerData(client);
|
this.SendLayerData(client);
|
||||||
}
|
});
|
||||||
|
|
||||||
foreach (LLUUID UUID in Entities.Keys)
|
foreach (LLUUID UUID in Entities.Keys)
|
||||||
{
|
{
|
||||||
|
@ -290,10 +290,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
/* Dont save here, rely on tainting system instead */
|
/* Dont save here, rely on tainting system instead */
|
||||||
|
|
||||||
foreach (IClientAPI client in m_clientThreads.Values)
|
m_clientThreads.ForEachClient(delegate(IClientAPI client)
|
||||||
{
|
{
|
||||||
this.SendLayerData(pointx, pointy, client);
|
this.SendLayerData(pointx, pointy, client);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -34,13 +34,14 @@ using OpenSim.Framework.Interfaces;
|
||||||
using OpenSim.Framework.Types;
|
using OpenSim.Framework.Types;
|
||||||
using OpenSim.Region.Caches;
|
using OpenSim.Region.Caches;
|
||||||
using OpenSim.Region.Terrain;
|
using OpenSim.Region.Terrain;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment.Scenes
|
namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
public abstract class SceneBase : IWorld
|
public abstract class SceneBase : IWorld
|
||||||
{
|
{
|
||||||
public Dictionary<LLUUID, EntityBase> Entities;
|
public Dictionary<LLUUID, EntityBase> Entities;
|
||||||
protected Dictionary<uint, IClientAPI> m_clientThreads;
|
protected ClientManager m_clientThreads;
|
||||||
protected ulong m_regionHandle;
|
protected ulong m_regionHandle;
|
||||||
protected string m_regionName;
|
protected string m_regionName;
|
||||||
protected RegionInfo m_regInfo;
|
protected RegionInfo m_regInfo;
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace SimpleApp
|
||||||
{
|
{
|
||||||
private List<ScenePresence> m_avatars;
|
private List<ScenePresence> m_avatars;
|
||||||
|
|
||||||
public MyWorld(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer)
|
public MyWorld(ClientManager clientThreads, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer)
|
||||||
: base(clientThreads, regionInfo, authen, commsMan, assetCach, httpServer)
|
: base(clientThreads, regionInfo, authen, commsMan, assetCach, httpServer)
|
||||||
{
|
{
|
||||||
m_avatars = new List<Avatar>();
|
m_avatars = new List<Avatar>();
|
||||||
|
|
Loading…
Reference in New Issue