aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/General/ClientManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/General/ClientManager.cs')
-rw-r--r--OpenSim/Framework/General/ClientManager.cs56
1 files changed, 48 insertions, 8 deletions
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 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using libsecondlife.Packets;
4using OpenSim.Framework.Interfaces; 5using OpenSim.Framework.Interfaces;
5 6
6namespace OpenSim.Framework 7namespace OpenSim.Framework
7{ 8{
8 public delegate void ForEachClientDelegate( IClientAPI client ); 9 public delegate void ForEachClientDelegate(IClientAPI client);
9 public class ClientManager 10 public class ClientManager
10 { 11 {
11 private Dictionary<uint, IClientAPI> m_clients; 12 private Dictionary<uint, IClientAPI> m_clients;
12 13
13 public void ForEachClient(ForEachClientDelegate whatToDo) 14 public void ForEachClient(ForEachClientDelegate whatToDo)
14 { 15 {
15 foreach (IClientAPI client in m_clients.Values) 16 foreach (IClientAPI client in m_clients.Values)
@@ -17,20 +18,59 @@ namespace OpenSim.Framework
17 whatToDo(client); 18 whatToDo(client);
18 } 19 }
19 } 20 }
20 21
21 public ClientManager() 22 public ClientManager()
22 { 23 {
23 m_clients = new Dictionary<uint, IClientAPI>(); 24 m_clients = new Dictionary<uint, IClientAPI>();
24 } 25 }
25 26
26 public void Remove(uint id) 27 public void Remove(uint id)
27 { 28 {
28 m_clients.Remove(id); 29 m_clients.Remove(id);
29 } 30 }
31
32 public void Add(uint id, IClientAPI client)
33 {
34 m_clients.Add(id, client);
35 }
36
37 public void InPacket(uint circuitCode, libsecondlife.Packets.Packet packet)
38 {
39 IClientAPI client;
40
41 if (m_clients.TryGetValue(circuitCode, out client))
42 {
43 client.InPacket(packet);
44 }
45 }
46
47 public void ConnectionClosed(uint circuitCode)
48 {
49 IClientAPI client;
50
51 if (m_clients.TryGetValue(circuitCode, out client))
52 {
53 m_clients.Remove(circuitCode);
54 client.Close();
55
56 // TODO: Now remove all local childagents too
57 }
58 }
30 59
31 public void Add(uint id, IClientAPI client ) 60 public void ViewerEffectHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock)
32 { 61 {
33 m_clients.Add( id, client ); 62 ViewerEffectPacket packet = new ViewerEffectPacket();
63 packet.Effect = effectBlock;
64
65 foreach (IClientAPI client in m_clients.Values)
66 {
67 if (client.AgentId != sender.AgentId)
68 {
69 packet.AgentData.AgentID = client.AgentId;
70 packet.AgentData.SessionID = client.SessionId;
71 client.OutPacket(packet);
72 }
73 }
34 } 74 }
35 } 75 }
36} 76}