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 ++++++++++++++++++---- OpenSim/Framework/General/Interfaces/IClientAPI.cs | 4 +- OpenSim/Framework/General/NullClientAPI.cs | 5 +- 3 files changed, 55 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework/General') 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); + } + } } } } diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs index 580a263..9c0771f 100644 --- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs +++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs @@ -34,6 +34,7 @@ using OpenSim.Framework.Data; namespace OpenSim.Framework.Interfaces { + public delegate void ViewerEffectEventHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock); public delegate void ChatFromViewer(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID); public delegate void ImprovedInstantMessage(LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID, uint timestamp, string fromAgentName, string message, byte dialog); // Cut down from full list public delegate void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos); @@ -242,6 +243,7 @@ namespace OpenSim.Framework.Interfaces void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID); void SetDebug(int newDebug); void InPacket(Packet NewPack); - void ConnectionClosed(); + void Close(); + event ViewerEffectEventHandler OnViewerEffect; } } diff --git a/OpenSim/Framework/General/NullClientAPI.cs b/OpenSim/Framework/General/NullClientAPI.cs index 2b6de9e..2fe46d6 100644 --- a/OpenSim/Framework/General/NullClientAPI.cs +++ b/OpenSim/Framework/General/NullClientAPI.cs @@ -52,6 +52,7 @@ namespace OpenSim.Framework public event StatusChange OnChildAgentStatus; public event GenericCall2 OnStopMovement; public event GenericCall6 OnRemoveAvatar; + public event ViewerEffectEventHandler OnViewerEffect; public event CreateNewInventoryItem OnCreateNewInventoryItem; public event CreateInventoryFolder OnCreateNewInventoryFolder; @@ -172,9 +173,11 @@ namespace OpenSim.Framework { } - public void ConnectionClosed() + public void Close() { } + + } } -- cgit v1.1