From 0bac4b430c264741b7f9e63b5d8fb781ba306c68 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 18 Sep 2007 12:13:44 +0000 Subject: * Handlerized ViewerEffect * Now there-is-only-client-manager * First step towards moving Logout and ConnectionClosed out of Client and into something else (which will let us get rid of ClientView reference to ClientManager * General posititvity, peace, love and understanding --- OpenSim/Framework/General/ClientManager.cs | 56 +++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/General/ClientManager.cs') diff --git a/OpenSim/Framework/General/ClientManager.cs b/OpenSim/Framework/General/ClientManager.cs index 0e45d03..274a2d3 100644 --- a/OpenSim/Framework/General/ClientManager.cs +++ b/OpenSim/Framework/General/ClientManager.cs @@ -1,15 +1,16 @@ using System; using System.Collections.Generic; using System.Text; +using libsecondlife.Packets; using OpenSim.Framework.Interfaces; namespace OpenSim.Framework { - public delegate void ForEachClientDelegate( IClientAPI client ); + public delegate void ForEachClientDelegate(IClientAPI client); public class ClientManager { private Dictionary m_clients; - + public void ForEachClient(ForEachClientDelegate whatToDo) { foreach (IClientAPI client in m_clients.Values) @@ -17,20 +18,59 @@ namespace OpenSim.Framework whatToDo(client); } } - + public ClientManager() { m_clients = new Dictionary(); } - public void Remove(uint id) - { + public void Remove(uint id) + { m_clients.Remove(id); - } + } + + public void Add(uint id, IClientAPI client) + { + m_clients.Add(id, client); + } + + public void InPacket(uint circuitCode, libsecondlife.Packets.Packet packet) + { + IClientAPI client; + + if (m_clients.TryGetValue(circuitCode, out client)) + { + client.InPacket(packet); + } + } + + public void ConnectionClosed(uint circuitCode) + { + IClientAPI client; + + if (m_clients.TryGetValue(circuitCode, out client)) + { + m_clients.Remove(circuitCode); + client.Close(); + + // TODO: Now remove all local childagents too + } + } - public void Add(uint id, IClientAPI client ) + public void ViewerEffectHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock) { - m_clients.Add( id, client ); + ViewerEffectPacket packet = new ViewerEffectPacket(); + packet.Effect = effectBlock; + + foreach (IClientAPI client in m_clients.Values) + { + if (client.AgentId != sender.AgentId) + { + packet.AgentData.AgentID = client.AgentId; + packet.AgentData.SessionID = client.SessionId; + client.OutPacket(packet); + } + } } } } -- cgit v1.1